Monday, January 28, 2013

How to become a better programmer?

By three methods we may learn wisdom:
First, by reflection, which is noblest;
Second, by imitation, which is easiest;
and third by experience, which is the bitterest.
- Confucius
These words are on my wall to remind me that there are easier ways of learning and in this post, I want to look at it from a programming perspective.
It is natural that experience will make us better programmers and that reflection is necessary to overcome challenges. But what I really want to focus on is the "easiest" way of learning, that is imitating. Two questions are important in this regard, the who and the how.

I always try to imitate the code of programmers that requires no explanation - code that is elegant and easily understood. For imitation to become a habit it has to be integrated into our existing workflow. I achieve this by downloading the source code and the javadoc of libraries and frameworks I use often using NetBeans. This allows me to seamlessly navigate to the implementation and documentation of APIs I'm using. I particularly pay attention to the following:
  • Interface design
  • Logging
  • Naming and package structure
  • Overall architecture
  • Testability of the code
  • Documentation
  • Structure of the code and how it is split into modules
I believe this not only helps you understand the APIs and libraries you are using, but also influences the way you write code -- for the better.

No comments:

Post a Comment