Understanding the "If's"
ODAIR GARCIA AROUCA
Especialista em sistemas | Analista de Negócios | Head de tecnologia | Mentor estratégico em negócios e tecnologia | Amplio o potencial das empresas pela gest?o de sistemas e de tecnologias
We know that when we are reading a book or an article or whatever the document is and it somehow induces us to reason about the theme, we put a question in our mind, which can point to another possibility, to something that is not there. exposed there, but that we already hitchhiked there with our perception and analysis. We often mentally name this and even paraphrase it with another connotation, generating new meanings and paths for our interpretation and simulation of possible escapes for the same theme.
In the development of programs or even in a spreadsheet, such as the one popularly known as Excel, from Microsoft, we have the possibility of creating simple and even more elaborate conditions, where more than one possibility fits for the information, that is, if the information for positive, it follows one path and if it is negative, it will follow another path. For this to happen, the use of "SE" or in programming using most of the market languages "IF" allows us to create these conditions in order to determine paths and appropriate responses to each situation.
What would become of the developer
without the "IF's"!
They really empower the logic created by developers, presenting different paths to be followed by the routine of the program under development and with that, it meets the necessary and seriously requested aspirations of programmers, who sometimes treat them with more conditions, building an epic sculpture in their programs, for the indentations made, so that the condition can be read in a clear and objective way by any developer who needs to go through it.
And speaking of indentation, which is nothing more than a text indentation applied in the elaboration of the source code of a program, which is fundamental for the application of followed commands, to be presented in an organized way and to make a quick understanding possible, by that one. that cover all your conditions:
If the variable X is equal to positive,
Show "Go ahead!",
If not,
Show "Try again".
Text indentation or indentation undoubtedly makes reading easier and more organized, but of course not everyone does it, either because of pressure or lack of habit, which does not mean that the program or routine does not work, just the ease of reading in maintenance ends up being compromised, see below the same above, but without indentation (indentation):
If the variable X equals positive,Print "Go ahead!", Else, Print "Try again".
A good comparison is to write a long text, without paragraphs and this is how the source code can be found, making some developers prefer to indent the code first, and then analyze it and this can be done with editors who already interpret and do this work, which no longer needs to be manual.
A good practice when setting up a condition is to always try to set it up with a positive question, that is, as an example, "If the variable X is equal to positive" instead of "If the variable X is not negative", because naturally we offer to respond positively to our propositions and this is also reflected in the reading and setting up of program conditions. Of course, depending on the applied logic, a condition is necessary, expressing the negative aspect of the same, for it to be met, but it's worth it, leave this construction of conditions as expected.
It is practically impossible not to be enchanted with these conditions, when you reach a good mastery over them, as they will teach you a lot and for a long time, perhaps I would even say, for as long as you need to assemble them, after all, they are good questions that they make us learn a lot about a subject and make us reflect for a long time on them.
Not necessarily, a question needs to have an "ELSE", it can only have the positive question and if it is answered, execute what is necessary and if it is not answered, it goes to the next instruction.
The greater the number of conditions linked to "IF NOT", the more complex the use of this condition becomes, but it is clear that it is often necessary to establish several questions, as they differ in several ways, in addition to also taking more time for the your interpretation, that although we are talking about nanoseconds, added to thousands of instructions, are precious seconds that could be, in several cases, avoided, but for each situation, a good analysis needs to be done and understood if it fits another command, as an example " CASE" or "CASO" that has a better performance, mainly for reports and queries.
And in our language with people, how many "SE's" can we apply interfaces, to ask what we need and interpret what we want? Good practice on the subject is worth it, but we always ask good questions!
***
My name is Odair Garcia Arouca, an IT professional for over 25 years. Married, father and writer. Author of the book Technology A Career of dreams - Behavior and procedure and also of the series of medieval books Callouny.
Get to know my book Technology - A career of dreams - Behavior and Procedure about a career in the IT area. Where I discuss difficulties, challenges, benefits, business areas, expanding careers, IT professional behavior and profile, as well as the professional's profile in relation to their environment. I invite you to take a fantastic and unforgettable journey in this book!
If you also enjoy literature with a dash of adventure, get to know the Callouny series, starting with the book Callouny - The stone town. I advise you to hold on to the chair, as the emotions will be strong! Good reading.
Follow me on Linkedin and subscribe to this newsletter to receive more content.
Also present on instagram @odairarouca