Programming Organizational Techniques & Interpreting Logic | CompTIA IT Fundamentals FC0-U61 | 4.2

In this video you will learn about using programming organizational techniques and logic components.

Organizational Techniques

Three techniques you can use to organize a program are:  pseudocode, flowcharting, and sequencing. Each technique is discussed in the following sections.

Pseudocode Concepts

Pseudocode is an informal high-level description of the operating principle of a computer program or other algorithm.  It uses the structural conventions of a normal programming language, but is intended for human reading rather than machine reading.  The purpose of using pseudocode is that it is easier for people to understand than conventional programming language code. Think of it as an outline or rough draft for your program.  Here’s a simple example of pseudocode:

  • Read the first name of a customer.
  • Make the first name a proper name (initial capital).
  • Read the last name of a customer.
  • Make the last name a proper name.
  • Read the customer’s phone number.
  • Print the first name, a space, the last name, a space, and the phone number.
  • Go to the next name.
  • Repeat the process.
  • Continue until all the names are output.

The purpose of pseudocode is so that you can help make sure that both programmers and non-programmers agree about what the program’s goal and the basics of how the task should be done.  Here’s an example of a refined pseudocode example after you have consulted with other programmers and managers:

  • Open file
  •        Do
  •               Read the first name (FirstName).
  •               Use PROPER to make the first name a proper name (initial capital).
  •               Read the last name (LastName).
  •               Use PROPER to make the last name a proper name.
  •               READ the phone number (PhoneNum).
  •               WRITE FirstName, space, LastName, PhoneNum.
  •               Go forward to next name.
  •        While not at end of file
  • Close file

The wikiHow page How to Write Pseudocode teaches you how to create a pseudocode document for your computer program.

Flowchart Concepts

A flowchart is a type of diagram that represents a workflow or process. A flowchart can also be defined as a diagrammatic representation of an algorithm, a step-by-step approach to solving a task. There are many visual diagramming products available to help you visualize your program. Here are some of the traditional flowchart shapes used for programming concepts:

  • Process (rectangle)
  • Decision (diamond)
  • Data (parallelogram)
  • Start/End (capsule)
  • Database (cylinder)
Basic Flowchart Shapes

Sequence Diagram

A sequence diagram, in the context of Unified Modeling Language (UML), represents object collaboration and is used to define event sequences between objects for a certain outcome.  A sequence diagram is an essential component used in processes related to analysis, design and documentation.

A sequence diagram can be drawn using visual diagramming software like Visio.  Creating a sequence diagram from source code can be useful when discussing a program with non-programmers.  Some apps can also convert a diagram into source code.

Sequence Diagram

Logic Components

Branching and looping are the two major types of logic used in programming.

Branching

Branching involves choosing between options based on one or more variables.

Branching Logic

Looping

To enable code to run as many times as needed until a condition is no longer true, you can use a technique called looping.  In Java, there are three types of looping: While, For, and Do…While. Other languages have similar looping logic.

Logic Loop

While Loop

In a while loop, the condition is checked at the beginning of the loop.  A while loop is a control flow statement that allows code to be executed repeatedly based on a given Boolean condition.

While Loop

For Loop

In a For Loop, the loop starts with the original value and then stops when the termination value is reached, using an increment specified in the loop.

For Loop

Do…While

A Do…While loop is similar to a While loop except that the test is performed at the bottom of the loop instead of at the top.

Do While Loop