Basic concepts in procedural programming
Today I decided it would be nice to share this on this blog. I am not saying it is a complete overview, nor that it is 100% correct. It's just my current understanding of the matter so far.
Data storageWhen writing a program, or just a simple script we usually want to use and manipulate data. Therefore we will want to temporarily store that data so the script can access it easily. Data is temporarily stored in the following ways:
- Variables (for single values)
- Arrays, or lists (for multiple ordered values)
- Associative arrays, or dictionaries, or hash tables (for one or more key-value pairs)
GroupingWhen writing code it helps to group lines of code that do a specific thing. And then we usually want to be able to call this grouped code block and possibly feed in some data and receive an output. This grouping can be done in the following ways:
- Procedures, or functions
- Subroutines: side effects only; no in- or output
Decision makingWhile we manipulate data we need to make decisions about what to do next; flow control if you will. To facilitate this, most languages have at least some of the following constructs of some form:
- if, else, then
- switch, case
RepetitionComputers are really good at doing the same thing over and over again and doing it ever faster. This repetition is also known as looping or recursion. Most commonly I have seen:
- Recursion: calling itself
If you are familiar with object-orientated programming you might want to add the concepts of classes, methods, and inheritance to this overview although OOP is not functional. I currently understand the basics of OOP only.
I know that this might seem awfully basic and maybe cryptic, but I hope that if you know a little programming, that it makes sense and that it will give an overview of the concepts regardless of what language you favor.