"He who controls the present, controls the past. He who controls the past, controls the future." – George Orwell
Learning new perspectives allow us to imagine the different ways something can be done. The ability to foresee or predict what happens when you have made a decision can save you from a lot of pain and time to fix problems. In fact, I prefer to avoid problems altogether. However, avoiding problems and not doing anything at all is not the same thing.
From experiences or lessons learned in the past, we can use that to make better decisions in the present. The decisions we make in the present then affects our future. Coming from George Orwell’s quote, if we can control our past, we can control our present and that will eventually determine our future. But logically speaking, no one can change the past and no one can predict the future. The only variable we can change is the present and what we do now.
As humans, what we can do is to think. We must be able to remember past lessons that were created from mistakes to avoid them now. Think ahead and figure out what may occur if this or that happens from following patterns. As you can see, everything is related to our thoughts and memories.
In software programming, there is a concept called control flow. It is the order of how statements, function calls and instructions are evaluated. Evaluated is when a particular set of tasks should be run or executed before, now or after a task is already running. All the different actions that are happening can be controlled by the programmer.
The programmer can determine which set of instructions should be executed first to create an efficient flow of progress that gives the desired results. What are set of instructions? To understand this, an intro to learning all kinds of computer language is a must.
In every programming language, there is a constant pattern and that is learning the foundation. The foundation usually consists of syntax (how to write comments using “// or /* … */”, identifiers or keywords), data types and values (numbers, strings, functions, arrays, objects, etc), variables (data type, declaration, and scope), operators (arithmetic symbols, logical, assignments) and control statements. All these items are combined to create a logical set of instructions that make up the interactive events happening on a website.
If-Else Statement
To match the theme of this post, I will focus on control statements. One type of control statement is the if-else statement that may stand for “if case A happens then do this, else B happens then do that”. For example, the following is a simple program to output the weather that depends on the number of degrees (temp) the user entered or coming from weather.com directly.
function weather (var temp) { if (temp < 60) print ("It's cold."); else if (temp < 80) print ("It's cozy."); else print ("It's hot."); }
This illustrates that no matter what temp is chosen by the user, they will receive an answer. The answers and conditions may be different for other people depending on their experiences. Yes, I do consider less than 60 degrees as cold and above 80 as hot. How about you?
Instead of saying “it’s cold”, you can even prescribe a remedy and say “don’t forget to bring a jacket” and send an email or sms to yourself. In fact, this idea is done by IFTTT and given a simple user interface. IFTTT also allows you to control the 60 or 80 values of that simple program by making them as variables.
While Loop
Another control statement is the while-loop. Its basic syntax is:
var x = 0; // initialize or starting condition while (condition is true) { statements; // an if-else, while, for, or other control statements and instructions x++; // depending on the condition, this is either an increment (++) or decrement (--) }
The x variable is needed so the program knows when to stop executing. If there is no x, this creates an infinite loop and causes the program to freeze and crash. While loops in business can be used like “while I have the energy to do A, I can get A(x) done, but my energy level does go down (since I am only human) and when x reaches a certain level, I need to stop and rest.”
For Loop
Similar to a while-loop is a for-loop. The syntax for a for-loop is:
for (initialize; condition; increment/decrement) { statements; }
As you can see, a for-loop is a simplified or condensed way to write a while-loop. For-loops are chosen instead of while-loops if the number of iterations is known. If programmers do not know the number of iterations, the while-loop is used instead where we wait until x becomes zero when x is decremented and its starting point is not zero. Sometimes, this gets to the point where x becomes too abstract that other set of instructions must be determined first before this particular loop is executed.
When a problem becomes uncertain, a function is created to initialize variables. These functions are called constructors which I am not going to cover on this post. As you can tell, a lot of information needs to be known beforehand for developers to create a concrete and problem-free software/website.
In terms of business, the more knowledge you gain and the more experiences you learn from, the better you get at identifying the uncertainties that can happen. Knowing the different cases for each control statement is similar to being able to control every action and outcome of your business. Why? Because if you have covered every case that occurs when you make a decision, you will know what to do to fix it or be able to avoid that case completely. What are the conditions needed for your business to run in optimal mode?