Relationship analysis between you and your code
Published: 2020-05-21 10:03:37

Software Engineering is a fascinating world, today millions of developers spend their time crafting new pieces of miracle and reading code snippets from developers across the planet. Let's talk about your interesting relationship with naming a simple variable today.

The naming of variables has an emotional meaning attached to the developer who has coded that program. Some of the factors influencing the code author to name those variables are:
1. Author's understanding of that engineering problem.
2. How the code author solved a similar problem earlier i.e their past engineering experience.

Also, there are some hidden factors which influence their decisions:

1. Their life journey so far.
2. Their emotional state during which the author is coding that program.

Fun fact: So the author came up with that variable name. If you don't understand the author's thinking behind naming that variable, you may struggle to understand the whole program due to that single variable name.‬

‪PRO TIPS:
1. Detach yourself from the name of the variables instead look at what does the program aims at doing and then you will understand the logic line by line.
2. As you have a different perspective of the world around you, you may come up with the idea of renaming those variables which according to you represents the logic better which is also a bias created by your brain. So don’t start cursing the original author of the program.

Example: Reversing a singly linked list in-place

‪Some people create temporary variables naming them as next and prev to accomplish swapping of nodes and pointers, logically and conceptually singly linked list have no previous pointer.

So now you are confused looking at the program what is the role of variable prev here. Instead of getting confused, you should think about what does this program aims to solve. You should go through the code and understand it based on the operations being performed. Suddenly you will have a Eureka moment, now you come up with the idea of renaming those temporary variables as nextNode and newNextPtr which makes a little bit more sense but maybe it's just for you.

That's why understanding the moral, events, decisions, actions of any story are much more important than the character names and their fashion sense in any movie or a book 😝‬

‪That’s one of the hidden reasons it's important to get your pull request reviewed thoroughly so that the code could be understood and be relatable by most of the people removing all the emotional and hidden past experiential baggage from it.

TIPS for reviewing a pull request, please check that:
1. PR is small enough (otherwise, break it up)
2. Variable names signify what they are being used for.
3. Code is readable and understandable.
4. Code is unit tested
5. The features are documented
6. Files are located and named correctly.
7. Files are following a decided naming convention like camelCase, PascalCase, snake_case, kebab-case.
8. Error states are properly handled
9. Bonus: Screenshots/screencast demo included

Keep creating and contributing to the world while exchanging your positive thoughts, ideas, actions to improve everything you come across in your life whether its a piece of code, place or a person. Happy Coding!

‪#meditativeAnalysisOfCode #codeForLife ‬#engineering #perspective  #understandingHumanMind #technology #javascript #coding #programming