WEEK: 7
Active: February 21st - February 27th
Work Due: February 28th @ 9:00AM

Program Logic

In general, program logic is a concept where the desired outcomes for a program (social, computer, institutional, etc.) are used to derive the “how-to” of getting there. Program logic is then used to evaluate the effectiveness of a program, plan, or system.

For our purposes, we will consider program logic to be goals for a software program, that are then used to derive instructions towards their end. We can describe the program logic of software based on what it is suppose to do, and how we are making it do that.

Control Flow

Control flow (also known as program flow), is the set of instructions defining how to accomplish the program’s goals. In computer science, a program is typically comprised of a set of instructions (aka, statements), which flow from one to the next based on their order and any sets of conditions.

Sequential Flow

In all of the code programs we have written or studied so far, the control flow has been sequential. That is, each statement (essentially, each line of code), is executed in order. When one statement is finishes, the next is then executed.

Demonstration of "Sequential Program Flow"

Conditional Flow

In addition to sequential flow, there is conditional flow or choice flow in programs. In conditional flow, the program is presented with a choice which allows it to execute one statement or another. Following the execution of the chosen statement, the program continues with sequential flow.

Demonstration of "Conditional Program Flow"

The path of a condition statement is determined through Boolean logic (i.e. is some condition true or false). If the condition statement or test results in a true value it chooses one way. Likewise, if the condition statement results in a false value, it chooses the other way.


Previous section:
Next section: