Glossary and Concepts

Program Flow of Control

Our second and third weeks focus on flow of control within a program:

Algorithm: Logical step by step outline of the processes to be implemented to solve a problem. Includes decision points with branches defining what to do for each case. An algorithm is language-agnostic, i.e., it does not use syntax specific to a particular programming language. For all but the simplest programs, an algorithm is an essential part of the software development process

Flowchart: A diagram that is a graphical representation of a process. Each process step is represented by a rectangle; each decision is represented by a diamond with branches coming off for each choice. A flowchart may represent one part of a larger program, breaking it down into manageable components.

Scenario: Describes a particular set of events, data values, or user choices that direct a program to flow in a predicted direction. Each scenario will have an algorithm and possibly a flowchart to define what happens in that set of circumstances.

  • Use Case: A style of scenario definition that describes one specific way in which the users will interact with the software.
  • “Happy Day” Scenario: The user(s) and data behave in the way expected; no errors happen
  • Alternate Scenario: Something untoward may have happened; perhaps an error; or the user behaved unconventionally (submitted “bad” data, clicked buttons out of order….)

Flow of Control: the order in which the steps of a program are carried out as determined by control structures within a program. Control structures include loops, conditionals, function or procedure calls

  • Loop: a flow of control structure that causes code to be repeated a specified number of times or based on a condition (while or until some condition is true); a loop that runs “forever” is called an Endless Loop
  • Conditional: a flow of control structure that determines what code gets executed based on a decision. The conditional to be evaluated may use a combination of several Operators. For example: If (X > Y) Or (Y < 0) uses relational operators along with a logical operator. The exact syntax will vary with language. Order of evaluation is extremely important!
  • Operators:
    • Arithmetic: Addition, subtraction, multiplication, division, modulus (remainder after division); in Scratch these operators are represented by +, -, *, /, and mod
    • Logical: Not, And, Or, XOR (exclusive OR)
    • Relational: =, >, <,  >=, <=
    • Boolean: True or False. The conditional IF block will evaluate to a Boolean result
  • Event: a trigger that a program or component  is “listening” for so it can react
  • Stop or Start
  • Nested Control Structures: A control structure may have another control structure nested within it: nested IF’s, nested LOOPS, etc.  It’s a good idea to use a flow chart, or pseudo-code (plain English statements rather than programming syntax), or otherwise draw out or act out what will happen to make sure things go in the intended order

Variable: a named data element representing a piece of information to be remembered. A variable should have a meaningful name! In our video game we may want to define a variable named Score. The code may set the variable’s value based on some condition. For example: If the hero rescues the princess increase the Score by 1000;  if the hero falls into a fire pit decrease score by 50.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.