When Guido van Rossum – the creator of Python – wrote PEP8, he had a visionary idea. Back to PEP8 later.
Ordinarily, many people would not see any difference between the following lines of ordinary English sentences:
I want to become a programmer.
I want to become a programmer .
The second line has two spaces between “want” and “to”, yet the first line has only one space. The second line
also has a space just before the ending period (dot), yet the first line does not. To a programmer, these
are serious differences which should not be ignored. As an interviewer for a
programming job, I would want to test if a candidate can easily spot such differences. If one has a difficulty seeing the differences between the two lines
above, then they would likely have difficulty adhering to programming rules. As I always say, programming rules are not so forgiving.
Let me give another example. If, in one instance in a report, you write "PEP8 (Python)". In another instance in the same report you write "PEP8(Python)". As long as you are aware of the two instances, but you have made no effort to distinguish between them, then clearly there is a problem with attention to detail.
This brings me back to PEP8.
PEP8 (Python Enhancement Proposal) is a document that provides guidelines and best practices on how to write Python code. It was written in 2001 by Guido van Rossum to improve the readability and consistency of Python code. This document is one good demonstration of why recruiters are always interested in a candidate's level of attention to detail. You cannot do so much with PEP8 if you do not pay attention to detail.
Consider the following function:
def function1(c):
""" this function does a computation by accepting one parameter, and
returns the computed value
"""
a = 1
b = 2
return c * (a + b)
Now, without observance of PEP8, you could easily write a=1 instead of a = 1, which is not good programming.
When I implemented my first Python project, I had not yet heard about PEP8, yet it had been in existence for several years. I can only blame lack of time for that. When I deployed the system, all was well, until a reviewer pointed out the lack of adherence to some of the PEP8 provisions. It was not too late. I had to do a lot of code refactoring to ensure as much compliance with PEP8 as possible. The beauty is that it enhances and standardizes readability and maintenance, and promotes best practice.
Finally, a practical example of attention to detail applies to my daily life – Moving Round a Parked Car before driving off.
People always wonder why I first
move round my parked car before I enter to drive off. For me, it is just another unwritten rule to
do this. So I get questions from onlookers such as: is there a problem with your car? I say,
No, I just move round to make sure that everything is okay before I drive off. Since I hardly see anybody else doing that, sometimes I wonder what is wrong with me. But it is already a rule for me, so I have to obey it.
How would it feel to drive a car off with a flat tire, or to drive over a cat that is sleeping just next to your tire? Not even just a cat. In a true story, someone reversed a parked car a few years ago and killed a baby who was seated just next to the tire. The mother of the baby had just gone to pick something and left the baby there. The things we do in our everyday lives define what we can or cannot do. Any lesson to learn, especially for the techies?
No comments:
Post a Comment