How to Predict Reusability Index of a Standalone Code

0

Is it possible to predict the reusability index of a block of code in a standalone mode? Meaning, given no information about the code, and just the piece of code, would you be able to predict or tell if the code is highly reusable or not reusable at all?

Before going into this, lets understand the basic fundamentals in relation with code reusability.

One myth I have come across while discussing the code reusability is that code should be made reusable when demanded by requirements. For example, one says that for reusable services, one should write reusable components and thus, reusable piece of code. When asked to many people, I got the answer such as one may need to know more information to tell whether a block of code is reusable or not.

Reusability is very much related with cohesiveness of the code in a way that a block of code, high in cohesion, can be found to be highly reusable and likely to have less coupling or coupling which is based on well defined requirements. And, what can be termed as highly cohesive code? The block of code which adheres to the SOLID principle of Single Responsibility can be termed as code having high cohesion.

Thus, when you are given a standalone block of code, try to read the cohesiveness of the code. Meaning, try to find out if the block of code is serving just one functionality or serving multiple functionality. If you are able to find this, you may be able to determine the cohesiveness of the code. And code reusability is directly proportional to code cohesiveness.

 

Ajitesh Kumar

Ajitesh Kumar

Ajitesh has been recently working in the area of AI and machine learning. Currently, his research area includes Safe & Quality AI. In addition, he is also passionate about various different technologies including programming languages such as Java/JEE, Javascript and technologies such as Blockchain, mobile computing, cloud-native technologies, application security, cloud computing platforms, big data etc.

He has also authored the book, Building Web Apps with Spring 5 and Angular.
Ajitesh Kumar

Leave A Reply

Time limit is exhausted. Please reload the CAPTCHA.