Inside the programmers brain

2 minute read

As a programmer, I think it’s very important to understand how our hardware works in our head. Considering this, I started to study the basic functions of the brain. I’ll not write up a deep science article here as I don’t have the skill to do so, but let’s summarize what I have learned.

Recent neuroscience has shown that a region of the brain called the prefrontal cortex (PFC) can switch between two different modes. One mode was known for hundreds of years. The PFC is responsible for calm decisions. It’s involved in focused attention. This area of brain was also known as a part we are using for thinking and planning. If we know what the next step is before doing it, then this is the part of our brain we are using.

prefrontal cortex

The second function of PFC has recently discovered and hard to test using controlled laboratory environment. That mode has a medium level of excitation and almost works like the chimp in our head, but the MRI records shows that all is happening in the PFC. For example, given the words “shoe”, “flake” and “drop” to the patients, the subjects might guess “snow”. Guessing the other part of these words does not require planning. We don’t know the second step before we are doing it. What is really interesting is the way the brain switches to one mode to other. It’s under stress when it’s doing so. In the animal world this makes perfect sense. The gazelle should consider the possible escape routes from the lion right before it gives the charge for the animal in it’s head and starts running. So it’s purely required for survival.

It’s also happening frequently in the programmers head. What we are doing for living - and what we would like to do - is planned implementation. We state the class names, methods and data structures and we would go through them one by one during the day. What is really happening in between is the magic. We usually under pressure to challenge deadlines, manage distractions and failures. It’s not quality code what is going out from our hands, we don’t even know how we wrote it or how it works, because the most of it was written under the second mode of our prefrontal cortex. Of course It’s only happening under pressure and shall be restricted by our wireframes we planned before. So it should be restricted inside class methods, should fit the data structures we planned with the first mode. If the planning mode was done under pressure, then there will be no valuable code and the day could rather been well spent out the hills paragliding.

The actual implementation could be written in the second mode only if the plan is good and was done when the brain was calm. Let’s say your senior developer planned the work for your Indian junior developer in your head you don’t have control over, but because you created the tests and wireframes correctly, He can’t fail it. The code He creates might be ugly, but the value of it is good enough and fit for purpose.