Getting Comfortable with Logic

Richard Adule
4 min readApr 1, 2021

While working as a Data Analyst and studding Software Engineering at Flatiorn school, my peers world often tell me that I have a firm grasp or understanding of logic. I would often ask myself;

“What makes a person good with logic?”

After facing project after project I realized a pattern within my code and how logic helped shape it. The contents if this blog give advice on how I approach logic and how I think it can help you to improve your programming capabilities. Some points will be more applicable than others.

First things first

Some people have more affinity than others when it comes to critical thinking, but don’t let discourage you to learn it. Even though I may feel more attuned with it, does not mean I don’t need to keep improving. It’s a continuous journey, and you won’t become good at it over night. Perseverance is key.

So, what are the tricks?

Visualisation

Some people are more visual than others, but I believe that majority of developers benefit from visualizing. There are various way to do this, like make an activity diagram, sequence diagram, or any other type UML diagram depending on what you are doing. There are many different diagram types out there, but especially for your own reasoning and understanding, don’t worry about the strict notation that comes with it.

The benefit of first sketching your logic before actually writing it down, is that it is easier to reason and improve your logic even before writing the actual code. I’d encourage to just sketch your diagrams on a whiteboard or piece of paper, but if you want to go digital, check out the free service draw.io, but the “faster” the better. Don’t want to loose time on the perfect sketch.

Code Challenges

It’s worth getting familiar code challenges, also known as “code katas”. They are great for brain exercising your logical mindset as they focus on a specific challenge that you should solve. There are several (social) platforms where you can find and create code challenges, some come with ranking and all that stuff. Often you can also review other people’s submissions, which is also great, as reading other’s code will help you improve you logical mindset.

Here is an example of one of the challenges on Codewars.

Reviewing other’s submission gives almost the same benefit as pair programming where you basically benefit from observing how another person might solve the same challenge.

Other sources for code challenges can be found if you google for coding interview questions from companies like Microsoft, Google and Amazon. Just try to solve them for yourself! Remember, visualize if you have problems understand the problem or someone’s solution.

Clean Code

This falls rather under the same category as the visualize things tip. Clean Code itself does not necessarily translate in better logical thinking, but it does assist you on getting there. The idea here is, if you learn on making your code more organized and clean to read, you will be able to understand the logic better. The easier your logic is to understand, the easier it is to find flaws in your logic or room for improvement.

When you have a method with 200 lines of codes and only variables named as single characters, you’ll have a hard time on reviewing your logic and find room for improving or find flaws.

I found “The Pragmatic Programmer” by Andy Hunt and Dave Thomas so be a a great resource, but as a starter, just googling “Clean Code” can return articles with good tips on writing cleaner code. When you’re up to it, consider reading the book.

Design Patterns

We could argue that Design Patterns don’t immediately fit in this list but are worth the mention. Design patterns are basically suggested solutions to common everyday problems that arise in software development. These solutions are on a more abstract level than primary logical thinking, but I do believe they help in building a more, clear solution to a logical problem.

The mainstream Design Patterns relate to Object Oriented programming and are not always applicable in all languages. To understand many of these patterns require some prior understand of Object Oriented design.

If you’re not working in an Object Oriented programming language, try to search for “Design patterns in programming language _” (fill in your language in the blank).

Summary

We looked at some methods on improving your logical mindset, but also some tools that help you to become comfortable and develop a better logic. The key is perseverance. Read and understand existing solutions and try solving challenges that do the trick. This is a continuous process, you never suddenly “have a logical mindset”. Brain exercise yourself with logical challenges and you’ll only get better at it.

Thank you for reading this article, if you liked it, give it a 👏 so I know it was useful to you. Suggestions and (constructive) feedback is more than welcome, what would you add (or remove) to this list?

--

--