Skip to main content

What are SOLID Principles? Explained with OOP Concepts.

 What are SOLID Principles? Explained with OOP Concepts.

What are SOLID Principles? Explained with OOP Concepts.
SOLID Principles

Software developers implement codes to meet the users' requirements and satisfy the clients. Some principles have to follow by software developers to enhance their code writing skills.

The SOLID principles have considerable responsibility to guide the software developers, to make the software design by improving the code quality. 


An American software engineer named Robert C.Martin created this principle.


Why do we need SOLID principles?

Advantages of using SOLID Principles.

  • Make the code more understandable and readable.
  • Make the code snippet as simple as possible by reducing the complexity.
  • Make the lines of codes flexible. Therefore the code snippets are updatable or modifiable when required.
  • To maintain the software codes easily.
  • To reduce the dependencies.
  • To make the code testable.
  • To implement the code. 

Solid principles have five(5) principles. The name is created by considering the first five letters from each principle. 

5 SOLID Principles
5 SOLID Principles
            

 Let us have a look at each of the principles separately.


          1. S - Single Responsibility Principle

This principle explains that a class has to contain one responsibility.


Example:

Let us assume a stock management project is implemented for a textile shop. There are many different teams, and they have to change one particular class to implement some functionalities due to distinct purposes. So the modified classes will become complex and incompatible due to several changes.


           2. O - Open Closed Principle

This principle explains that a class can handle extensions without being modified. So if we need to add some functionalities to previous classes, it is better to create another abstract class or interface and include the functionalities. It helps to save implementing time. 


Example:

Let us assume there is a student management system for a university. The students can be undergraduate students or post-graduate students. There can be some attributes that are common for both classes. Then the undergraduate students and post-graduate students can be considered as child classes and the person as the parent class to store the common attributes. So both the child classes inherit the parent class.


          3. L - Liskov Substitution Principle.

This principle explains that the parent class has to be substitutable with the child class.


          4. I - Interface Segregation Principle.

This principle explains the separation of the interfaces.

Due to the separation of the interfaces, a particular client will be given access to relevant functionalities. That particular client will not access the interfaces that are irrelevant.


          5. D - Dependency Inversion Principle.

This principle explains that the classes have to depend on interfaces or abstract classes. It should avoid the dependability of concrete classes or functions. This principle helps to enhance the reusability of the code.


Conclusion

Thanks for reading my blog by spending your time. I hope this blog will help you to gain knowledge about solid principles.


If you like this blog, share it and show some love.


You can read more of my future blogs by following me through my social media.

LinkedIn  Twitter   Dev Community


References

  • https://medium.com/backticks-tildes/the-s-o-l-i-d-principles-in-pictures-b34ce2f1e898
  • https://www.digitalocean.com/community/conceptual_articles/s-o-l-i-d-the-first-five-principles-of-object-oriented-design
  • https://www.bmc.com/blogs/solid-design-principles/#:~:text=SOLID%20is%20an%20acronym%20that,some%20important%20benefits%20for%20developers.

Comments

Popular posts from this blog

What Is SMTP Protocol?

What Is SMTP Protocol? SMTP  Email is a method of communication. Nowadays, people around the world use email services. Exchange information with electronic devices is possible with email. The exchange of information can be between two people or a group of people. Let us know about a protocol related to transferring email. SMTP SMTP stands for Simple Mail Transfer Protocol. It is a protocol used to send email through the internet. Uses TCP (Transmission Control Protocol). It is an application-level protocol. It uses commands to mail authentication and transfer email. Examples of commands: HELO – It is the first command in SMTP. To identify the sender’s (server) domain name DATA – To send data of mail body by individual lines to the SMTP. RCPT – To identify the receiver of the email. Repeat the command with address for more than one receiver. MAIL – To start the transferring of the email. QUIT – To stop the conversation of SMTP How does SMTP work? The user fills in the content of the...

Go Language And Its Environment Set Up

  Go Language And Its  Environment  Set Up Features of Go language Go is a programming language, which is designed by Google(2007). Why it is introduced? 1. Limitations in the hardware. The performance of the system has to be increased. Using a large number of hardware parts like the transistor and the processor, which is not possible. When one of them increases the cost will increase or the performance will reduce. 2. The code is easy to maintain The code written with Go language has a simple and understandable syntax. These features help to maintain the code easily. Features of Go language Open-source. Used at the backend. Made of packages Performance is greater. Has garbage collection. Easy to read the code. Throughput is better. Has garbage collection. How to set up the environment to start coding in Go language. Initially go to  The Go Programming Language (golang.org)  and download Go language by clicking the relevant link(select the correct Operating Syst...