e-Zest members share technology ideas to foster digital transformation.

Code Reuse – Why too much is too bad?

Written by Shailesh Kulkarni | Dec 21, 2016 10:11:56 AM
Reusable code is considered as an important entity in the world of programming. Not writing the same piece of code again and again, instead moving ahead with building something new based on what has been written already. Though with best intentions, we continue to practice the same approach, still we fail to understand the essence of it and hence, we are not able to deliver the results as expected.

Reusing your code doesn’t mean how quickly you get to develop your final product; instead it means how rapidly you are able to modify it.
So, as you move further with code reusability, here are few things you should consider.

At present, microservices are ruling the backend world. However, applying the reuse approach to micorservices can work out really well. Microservices are great in terms of code reusability, as they are based on the idea of fragmenting large systems into smaller chunks. However, reusing any internal logic between the different microservices might not work perfectly.

Another important factor you must think upon is while reusing the shared code. Consider you have developed and deployed same product for three clients. Your code is shared amongst them. Now comes the irony, reusing the code which is already written can enable us in saving lot of time but, if your code is shared inherently it will be much difficult for you to modify it. This can be a complex process because once your code is deployed, you should consider all parameters and keep the client into your mind while changing the code as it might affect all of them equally.

Furthermore, while developing code for your project, it is a must that all of the development is done by the core team members. Because, if any of the modifications are demanded by client and the development is done by other team in the same organization, this might result in a huge knowledge gap. Apart from it, the core team members will have to re-implement the functionalities as per their own set of rules.

If you are looking to alter database queries or APIs, code reusability might actually make sense. But, if there is some part of the code which is supposed to be regularly modified then it is better to develop your own solution. Regular changes in the code are directly proportional to the cost and the benefits of the deployed product. There are high chances that the frequent code changes might incur high cost and result in losing the core value of the code. So, regular changes in the code must be least important, instead it is necessary to think upon building your own solution.

Lastly, it is essential to set clear boundaries and decide the best practices code for reuse without hampering other components of the code. Code reusability must be considered only when it is required and must be carried out carefully.

Code reusability if not done appropriately can be harmful to your product and can impact your client credibility. However, code reusability can provide with lot of benefits if done correctly.