In this blog post we will discuss about What are the important paradigms for Developing the Clean Object-Oriented Code?
We should always keep in mind below key points when you write code in your application:
- We should use an Interface (or the Super Type) not the implementation.
- Classes Interacting each other should be loosely coupled among themselves.
- We should write code in such a way so that it should implement tight encapsulation. Use of public and static variables should be avoided wherever possible, they introduce coupling and make testing of classes tough. Avoid the Singleton Design pattern wherever possible.
- We should always reuse the existing code using Inheritance, Composition and Utility Methods. We should strictly follow the Do not Repeat Yourself (DRY) principle.
- We should use Has-A relationship because Has-A relationship is better than Is-A relationship it offers more flexibility, see Decorator Design Pattern in java.io. * package for more details.
- In case of multi-threaded applications, we should use immutable objects to represent the state.
- We should make proper use of Design Patterns wherever possible.
- We should always use up to date software dependencies & make best use of latest technology available to us.
You may also Like:
Why Java is not 100% Object-oriented language?
Can we call static method with null object?
Can we override static method in Java?
What will be the output of following java program?
What is the difference Between java.util.Date and java.sql.Date in Java ?
Why Prime Numbers are considered in writing certain algorithms like hashcode()?
That’s all about What are the important paradigms for Developing the Clean Object-Oriented Code?
If you have any feedback or suggestion please feel free to drop in blow comment box.