Intro to Programming

Get Started. It's Free
or sign up with your email address
Intro to Programming by Mind Map: Intro to Programming

1. Basic Terminology

1.1. Procedures:

1.1.1. Why do we use Procedures? We use them to produce "side effects." eg) in the first image, we called the "Def main()" procedure from the procedure we defined as "main()"

1.2. Functions: functions return a value to be assigned to a given variable. in the example we defined "value = function()" meaning that that variable will hold the value of whatever return value "Def function()" returns.

1.3. Parameters

1.4. Variables: Are a named part of the computer’s memory which can have its contents changed as the program executes. good practise is to write them like "variable_1" using underscores instead of spaces and the first letter is non caps

1.4.1. Global Variables:

1.4.1.1. explanation with example: Global Variable in Ruby - GeeksforGeeks

1.4.2. Local Variables: apply specifically to function it is defined in.

1.5. Arguments: Both functions and procedures can carry arguments. Arguments are data that is passed from one block of code to another. The argument is given a name (like a variable name) in the receiving procedure/function.

1.6. Reserved words:

2. Ruby Memory Organisation:

2.1. 1-Code-Area: The code area stores the machine code from your program:

2.2. 2-Stack-Area: The stack stores frames that manage the function and procedure calls. Everything on the stack has a fixed size, with the computer managing this memory allocation.

2.3. 3-Heap: The heap stores dynamically allocated memory.

2.3.1. Allocating Space on the Heap:

2.4. Pointers:

3. Testing and debugging

4. Week 3 - Topic 4 Selection and Iteration

4.1. blocks

4.1.1. Selection/branching: Use this when you want to Select a consequent outcome based on a set condition

4.1.1.1. If statements (basic structure)

4.1.1.1.1. IF-ELSE variation: It is used if you want to have multiple conditions stated for each selection.

4.1.1.2. Case statements (basic structure)

4.1.1.2.1. Further explanation

4.1.1.3. creating CONDITIONS: (look at source)

4.1.1.3.1. Link to source: Ruby - Operators

4.1.2. Iteration/looping/repetition

4.1.2.1. Control variable: determines when to stop the loop

4.1.2.2. Pre test loop

4.1.2.2.1. WHILE loops: If you want the loop to break based on a condition other than the number of times it runs, you should use a while loop. Uses "Count" as a control variable

4.1.2.2.2. FOR loops: you should use a FOR loop when you know how many times the loop should run. "Count in 1..4" is an auto increment of the counter

4.1.2.3. Post test loop

4.1.2.3.1. UNTIL loops (more simple than break statements, most preferred post test loop)

4.1.2.3.2. BREAK statements (NOT RECOMMENDED IN RUBY)

4.1.2.3.3. Redo Loops

4.1.2.3.4. TIMES loop: Use when you know the number of times you want it to run

5. Data Types

5.1. Basic Data types

5.1.1. Booleans:: True or False values

5.1.2. Floats: non whole number

5.1.3. Strings: Letter values

5.1.4. Integers: Whole number

5.1.5. Arrays: An array can store multiple data items of all types

5.1.6. Constants: first character must be a capital. Data values DO NOT CHANGE

5.2. Complex Data types

5.2.1. Can be sourced from libraries. eg) get "date" (from ruby)

5.2.2. Can be custom data (programmer created)

5.2.2.1. Classes

5.2.2.1.1. Tokens: used to allocate memory to a type. this is where you assign values to the types.

5.2.2.2. Enumerations: used to define set of constants (custom named parameters that don't change eg) the music player task)