Category Archives: Reusability

Single Responsibility Principle with Java Code Example

single responsibility principle with Java example

Single Responsibility Principle (SRP) is one of the most important object-oriented coding principle which, if followed religiously, can help you write a very good quality code. Here is what SRP states: A block code representing class or method should have just one reason to change In other words, Single Responsibility Principle can be stated as the following: A block of code representing class or a method should do just one thing and do it very well In yet another words, SRP can also be stated as the following: A block of code representing class or method should have just one responsibility or serve just one functionality Pictorially, decide for yourself …

Continue reading

Posted in Maintainability, Reusability, Software Engg, Software Quality. Tagged with , .

How to Predict Reusability Index of a Standalone Code

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 …

Continue reading

Posted in Reusability, Software Quality. Tagged with , .

Stay Single and Get Admired for Your Code

You might be wondering on the relationship between staying single, getting admired and coding! And, then, staying single forever 🙂 is something which may not be liked by most of us. So, what is this blog all about? Well, with “single, I am trying to point at “Single Responsibility Principle” and with “stay single”, I am pointing towards writing code based on “single responsibility principle”. Well, as the title of this blog goes, if you keep the “Single” responsibility principle (SRP) in mind while writing your code, there are high chances that you will end up with a great piece of code which will get liked by many including your …

Continue reading

Posted in Maintainability, Reusability, Software Quality. Tagged with , , , .

How to Write Re-usable Code

In my software quality sessions, one of my favorite questions had been “how to write re-usable code”. The most common answer has been following: Once one identified the re-usable components based on the functionality, once can write the components accordingly such that it can be reused. However, this argument required one to identify the reusable components at the design time. The question still remained. How would one write a code that can be termed as re-usable even if the component is not required to be reused at the moment? Another question that I ask is if it is possible to look at the code and say if this is a …

Continue reading

Posted in Maintainability, Reusability, Software Quality. Tagged with .