There is something called the “ethic of reciprocity”, perhaps
more commonly known as the Golden Rule. In short it says that you should act towards others in the same way that you
would wish them to act towards you. While this might be worth striving for in everyday life,
I have also found it a useful thought in relation to code design.
As a consultant, you usually spend time with a code base during a certain amount of time,
and then you move on to a new assignment. This means that you will every now and then leave
your code behind for someone else to maintain, and you will also every now and then get
somebody else’s code for you to maintain. The act of trying to figure out the structure
of a large project can be a real pain. Even when it is code that you have written yourself
a few months ago, it can still be a rather challenging task, if it is not very clear where
to look for things. This is important to keep in mind while writing code; some day, someone
else will need to sit down with this code and try to find his or her way through it.
Let’s call it “coder’s ethic of reciprocity”:
Leave your code in the same state for
your successor, as you would wish to find your predecessor’s code in your next project