Pay Attention To Details

When you see codes written by some programmers, you simply want to admit that some programmers were made right from heaven. They simply came down to earth to teach others. Well, this is because of the simplicity and clearness of the code. You immediately fall in love with such code and wish and hope that one day you code that way.

But as we all know it, no programmer was made in heaven. The whole programmer factory was built and designed right here on earth and every single programmer at one point or the other was a learner. What makes the difference? In my own opinion, what makes the difference is paying attention to details. It is paying attention to every piece of code they write. They pay attention to the names they use, the number of lines they use and most importantly pay extra attention to what other programmers would simply overlook.

What then are these small details that these programmers pay extra attention to? I would try to list some of the few ones I can think of.

  1. Naming: The most important detail any programmer can give attention to is naming. The names you give your classes, your variables and methods would definitely make you stand out when writing your code. Imagine naming your class with a name that everyone has to ask you what the meaning is. Well, that already creates an impression in the mind of the reader of your code. It simply means that there are more names in your code that would be as bad as the first one. Pay close attention to names. It does not necessarily mean it’s a name that everyone would understand. But it should be a name that is easy to understand even if you do not understand in the beginning.
  2. Clutter: Clutter simply means anything your code can do without but still exists in your code. This includes all the dead codes and comments you no longer need in your code. It could simply be a piece of code that never gets executed. It is any piece of code that would still make your code just as beautiful as it is without them. Sometimes, we find it difficult to determine whether some piece of code is a clutter or not. Simply take it out and see its effect on your code. If your code still remains as perfect as possible, then its a clutter, otherwise fix it back.
  3. Simplicity: Simplicity always wins. If you cannot make your code as simple as possible, then you probably do not understand it in the first place. Most people say I understand what I wrote, but writing a code is not meant to be understood only by the writer of the code but by the numerous number of people that would read the code long after the writer of the code has forgotten they have ever written such code.
  4. Convention: When you write following a certain pattern, you have a convention. Diligent programmers use the convention in their code to help keep the reader focused on whatever it is they are doing.  The names, spacing, variable declaration and much more are simply consistent and one can pretty much understand how the next flow would be. You need to decide on which flow you want to follow and follow through with it. Do not start in one way and end up in another.
  5. Spacing: Have you ever found a variable declared at the top of a file and found its implementation right at the end of the file. Closeness to source of implementation matters a lot for code. When you want to create a private variable, declare it close to its source of usage so that the reader does not get distracted while trying to understand what you are trying to do.
  6. Small Scale: Small scale always wins. Use few number of parameters, use few lines for methods, use short useful names rather than long names. Create few functions in a class and ensure that classes perform a small amount of responsibility.

These few points are some points I believer diligent programmers pay attention to when writing code and I believe that if we also keep up with these points, our code would definitely be better than they used to be.

Leave a Reply

Your email address will not be published. Required fields are marked *