Building Blocks...

When thinking about how to build a program, you need some vocabulary and some pieces to build programs out of. There are a relatively small number of basic building blocks to build programs out of:

  1. Data
  2. Control Structures
  3. Loops
  4. Data structures
Each one of these deserves and needs extensive explanation. But first, here is a quick overview of these.

To start - lets talk about about data.

In order to make sure that we don't make this specific to any particular language I will just talk about fairly basic data types:
  • Integers (whole numbers)
  • Reals (decimal numbers)
  • Booleans (true or false)
  • Strings (text)
With these four types (possibly in combination) you have enough to store just about anything that you need to.

Control Structures provide you a way to decide which section of code is run based on some condition. Examples of control structures are:
  • If Then
  • If Then Else
  • Case (or Switch)
The If-Then lets you run a block of code only if some condition is true. If-Then-Else allows you to run either one block of code or another depending on the value of some condition. The Case allows you to choose between several specific values to decide which block of code to run.

Loops let you run the same block of code zero or more times. There are two basic versions:
  • For loops
  • While loops
A For loop would be used when you know exactly how many times you want to run block of code. A While loop lets you run the block of code until some condition occurs.

Finally, Data Structures allow you to combine multiple smaller individual pieces of data together. The simplest data structure is an Array. An array is basically a numbered list which allows you to access any entry by using its position in the list as an index. As a starting point - just the array is enough to begin. Data structures are actually a very extensive subject that has entire books written about them.

And that is the basic vocabulary that I will be using.

Next time, I'll be talking about constants and variables - the two ways to have data available to your program.

Comments

Popular posts from this blog

Is trying to program making you loopy...?

Laid out (arrayed) out before you...

Constants and Variables....