I started my programming 20 years back. I learnt computer programming by learning from books, writing algorithm in paper and then compiling the same at the computer terminal. In those days , I neither had personal computing power and access to internet and we had limited shared computer time. I used to write algorithm in paper and get it right before going to computer. Things seems to be changed for young programmers today.
A developer working with me has got existing libraries from the internet and has been using in the project. The developer has been completing things faster and had a good impression. I missed to follow code review closely with first impression. Deep in to the project, I found that the checked-out project code does not compile and the code compiles and works for the developer. I upgraded my development environment and then the same condition continued and made me to to walk-through the code. The code seems to be cumbersome and is not in optimal way and the code is not modular and need re-factoring. Once code is compiled, I find the code has performance issues and does not work on simulator and works only on the actual device.
- The developer shares that he is using the API provided by the platform owner and asks me a question should we not follow the recommendation and assume it is right.
- The developer is not aware that he needs to check and verify the copyright for the third party external code.
- The developer has not spend time to understand the whole external code and identify which part of the code is needed in the project. He has referenced the whole library, when only one class is being used for the project goals and there is no reference to other classes in the project from this single class or any where in the project.
- The developer points that some of the reported issues originate from the external code.
Today every one has access to internet. No body wants to start coding a real-world project from scratch any more. I hated the situation I have put myself failing to enforce the code review process from day one. Then I calmed down myself and saw a need to educate developers to make use of existing code. My suggestions are
- Find whether required code exists in external library: Find existing snippets of code to build my project upon. modern programmers usually scavenge parts from existing projects.
- Support for external code: You might use a popular MIT library or jQuery library with large developer following or code from a unknown third party developer or code that has not been updated for months now. In all the cases, you are responsible to perform home work to assess external code capabilities and limitations.
- Validate whether external code suits to your need: Compile and run the code on various inputs, debug the code with “print” statements. Does the code solve your specific user case? Check for copyright violations. Ask permission to your architect/manager to use the code.
- Doubt the external code: You do not want to reinvent the wheel, but remember it is hard to figure that existing code can be molded to do what we want to achieve. One is to see whether existing code based has support for bugs that can be reached in case of problems in the future.
- Own your code and external code as single code base: Once you decided to make use of external code, if the external code does not play nicely with your code, you are solely responsible for the boundary conditions and race conditions of the entire code base. You also own the modular structure of the entire code-base.
- Re-factor: Cool. You have got things working as quickly as possible. Identify patterns and repetitions in my code and create abstractions to clean up and make the code modular. The more you re-factor, the interfaces between your code and external code becomes clean and you get a better grasp of the code.
Let me complete blog with my call on programming and add some questions that I am going to ponder upon.
“There is no short-cut to be skilled at programming other than practice over many years. To practice long, you need to be passionate about what you do.”
- What is the disconnect between how people actually build code and how we teach programming in classrooms?
- How to mirror real-world programming scenarios in the classroom?
- How the developers taught the responsibility involved with software development?
- Can the developer me made to practice to write unit tests in college itself?