Skip to main content

How To Code: How To Improve Logical Thinking For Programming

how to improve logical thinking
Photo by tian kuan on Unsplash
There are multiple techniques shared on the internet on how to improve logical thinking or # logic building tips for programmers or how to think like a programmer. But those techniques does not work. I mean they work but... the hard way. It is like someone is asking you to taste a delicious food without opening your mouth. Can you do that? Probably you can come up with a super creative way but that's not the way it works. There is one most important process to follow before applying those techniques. You can say, it is a prerequisite to fully utilize those logic building technique. And it is, understanding the flow of data inside your code. The code that you haven't written yet. Wait... What?

I am not kidding. You can understand your code that does not exists yet by using your imagination power. The power that makes us human, human. If you want something done and you cannot imagine it, you will never get it done. Here, I will tell you how programmers in the beginning develop their imagination power in order to build strong logical thinking ability.

The technique discussed here data pipeline technique, similar to instruction pipeline but with a higher level of abstraction. The purpose of using this technique is to imagine what kind of data flow is required in order to convert input data to output data. Once you successfully develop your sense of imagination to foresee that what would happen to a given data after only one statement of code executes, then you can easily imagine a long flow of data transforming from input shape to output along the way. And it gains momentum as you keep developing your data flow imagination skills. We will call this technique logic pipeline in the rest of the post.

Why to use logic pipeline?

The most important thing in logic building is how well you understand data flow, a sequence of steps or stages where data transformation may occur at each step. In order to understand data flow, I have divided it into simple steps:
  1. identify input data
  2. identify source(s) of input data
  3. identify intended outcomes of the program
  4. apply the required transformations on input data
Steps from 1- 3 are quite easy and require less effort. However, step 4 is a tedious task. It is the core of logic building in programming. Each of the steps is explained below:

1. Identify input data

Before writing a single word of code, identify the input data. Input data is the raw data that is given to the program in order to process it and produce the intended results. Examples:
1. Images are the input data for picture editing software.
2. Financial data is input data for business analytics tools.
3. User input is input data for a game.

Study the problem you are writing code for and identify the input data for your program. Input data is the key to accurate program. You cannot move further unless you have the key. Unless you have an idea of what are you dealing with, you cannot make your next move.

2. Identify source(s) of input data:

Once you identify input data for your program, I think it would not be that much difficult to identify its source. By source I mean the place where the data is coming from. It is not necessary that you will always receive data only from one source. The data may come from many and heterogeneous sources. For example, sources of data in examples mentioned above could be:
1. Camera, Hard-drive, Flash drive or Internet.
2. User input, excel sheets or other docs stored on hard drive.
3. User or another code executing on the same or another computer.

3. Identify intended outcomes of the program:

The intended outcomes of a program are the values we want it to create for us. These are the achievements the user will receive after successful execution of the program. For example, indented outcomes of the above mentioned examples could be:
1. Visually improved images
2. Meaningful insights about the business
3. Game aesthetics and dynamics

So until this step, you know what kind of data you have, where is it coming from and where it needs to go. Logic building is just taking some sort of data you have in your hand to some other sort of data.

4. apply transformations from input data to output data
Once you identify what you have in your hand and what you want to turn it into, all you need to do is to say the magic spell. Logic building is simply a sequence of steps which gradually convert input data to output data. You know where to start and where to go. Take small baby steps and move ahead. By moving I mean the movement of data, convert data from one level to another level or from one form to another form. It is just an activity of path finding in a puzzle game where basic structures or statements of programming (Loop, Conditional statements, I/O, Math operators etc) are pieces of the puzzle. You keep connecting the dots and the magic happens by itself.

In order to become good at making logic, you must know what would happen to data after it passes through a function or what would happen to current data after a line of code executes. The more lines of code or functions you can forecast about, the quicker you can make logic. Let me explain with an example: If someone named A can tell you what will happen to data after 1 line of code executes, it will take him/her t time to make a logic L. If someone else named B can tell you what will happen to data after 2 lines of code execute, it could possibly take him/her t/2 time to make the same logic L.

The main point of this discussion is that at any point/line in your program or logic, you should know the following:
  1. input data you have at the moment
  2. desire output data
  3. transitions from input to output
  4. a list of basic operations on input data and their results without executing the operations.
In the next few days, this step will be explained further with the help of visuals and examples.


Popular posts from this blog

How Big Data Analytics Can Help You Improve And Grow Your Business?

Big Data Analytics There are certain problems that can only solve through big data. Here we discuss the field big data as "Big Data Analytics". The big data came into the picture we never thought how commodity hardware is used to store and manage the data which is reliable and feasible as compared to the costly sources. Now let us discuss a few examples of how big data analytics is useful nowadays. When you go to websites like Amazon, Youtube, Netflix, and any other websites actually they will provide some field in which recommend some product, videos, movies, and some songs for you. What do you think about how they do it? Basically what kind of data they generated on these kind websites. They make sure to analyze properly. The data generated is not small it is actually big data. Now they analysis these big data they make sure whatever you like and whatever you are the preferences accordingly they generate recommendations for you. If you go to Youtube you have noticed it kn…

How Computers Understand Human Language?

How Computers Understand Human Language? Natural languages are the languages that we speak and understand, containing large diverse vocabulary. Various words have several different meanings, speakers with different accents and all sorts of interesting word play. But for the most part human can roll right through these challenges. The skillful use of language is a major part what makes us human and for this reason the desire for computers that understand or speak human language has been around since they were first conceived. This led to the creation of natural language processing or NLP.
Natural Language Processing is a disciplinary field combining computer science and linguistics. There is an infinite number of ways to arrange words in a sentence. We can't give computers a dictionary of all possible sentences to help them understand what humans are blabbing on about. So, an early and fundamental NLP problem was deconstructing sentences into small pieces which could be more easily…

The Limits of Artificial Intelligence

If you are here, it means that you are familiar with term artificial intelligence. Either you have read about it in school or have seen it in sci-fi movies or somewhere else. Talking about the limitations of AI, let me ask you one simple question first, do you know the definition of AI? You might be thinking to answer me with a yes, yes I know what is artificial intelligence. But what if I tell you that AI is a buzzword and it is almost impossible to properly define. It is this way because the definition of artificial intelligence is moving. People don’t call the things AI that they used to call. For example, a problem that seemed too complex to be solved by human and was solved by AI algorithm is no longer a problem of AI. Playing chess, is one of the examples. It was considered the peek level of artificial intelligence back in previous century. Now it hardly fits the criteria for AI. It is presented to the world as a super power that when given to a computer, it magically starts li…