What's the advantages of SOLID principle in OOP Java

SOLID Principle In OOP Java

As is our nature of laziness, we tend to write codes as if we don’t look for future potential disasters. As long as the codes work, it will just work fine. And I even recommend that if you are just beginner coders, you shouldn't care much about what principles you should use to write code.

The first step of becoming a developer is just writing lots of code, no need for structure, or anything else, the only thing that matters is that the code works and returns output as it expected. In other words, you need to master the code's syntax, setup, debug, the environment, etc.

As you gain many experiences over the years as a software developer, then you will have the sense to write better code, at this point, you start to look at design principles, design patterns etc.

The Advantages of the SOLID Principle?

In object oriented programming (OOP), we must know about the SOLID principle on writing better codes. But why should we use SOLID principles?

- The Solid principles intended to make easier, understandable codes.

- The big picture of using solid principles is the extensibility, maintainability of the codes.

- It makes your code loosely coupled, it reduces the dependencies breaking, your code still works even if some dependency is still in the development process or if you remove it.

- When the codes is change, it doesn’t affect any other functionality that using it

- your Project is more maintainable, testable, scalable, and reusable.

- Avoid the bad design of the software, because everyone has different rules and mindset about writing codes.


SOLID consist of 5 different aspects, which they are as following:

S - Single responsibility, every class should only have one responsibility

O - Open closed, every class should be open for extension and close for modification

L - Liskov substitution, If a function uses pointers or references to base classes, it must be able to use objects of derived classes without knowing it.

I - Interface segregation, splits large interfaces into smaller and more specific

D - Dependency inversion, module should not depend on other module so it’s loosely couple


That’s its basic introduction and the advantage of using SOLID principles when writing codes. In the next tutorial, I will give some example codes in Java to demonstrate better each of the principles.


Popular posts from this blog

ERROR 1348 Column Password Is Not Updatable When Updating MySQL Root Password

How To Create Spring Boot Project Using Netbeans

Spring Kafka - how to use ReplyingKafkaTemplate send and reply synchronously

Upload and Download Rest API using Spring Boot Reactive WebFlux

What Is My Localhost IP, For Windows User?