Skip to content

SOLID: Towards Powerful Software Development

It is known that the software ecosystem has become pervasive. Programmers around the world grew to 23.9 million in 2019 and are expected to reach just under 29 million in 2024 according to Statista. Despite that and what developers have seen, more than 80% of applications are not utilized. In this blog, I will take you on a simple journey of understanding SOLID principles towards powerful software development.

SOLID-Towards-Powerful-Software-Development-GPI-Blog

Software development has a simple design process: it starts with architecture, ends by testing then passes by coding. Programs are essentially lines of codes written to perform specific functionality. At some point, this functionality will need modifications to adapt and evolve. Programmers need to remember the golden rule when starting to code: that software has to be maintainable, extensible, updatable, and testable.

 

What does a “Clean Code” mean?

You can think of a “clean code” as the key that will accompany you throughout the software development. Oftentimes, developers would complain that it is difficult to read and understand the code. Whether it is too long, ambiguous words, or as if someone just made it up. It’s funny that sometimes the one who wrote the code is the one who couldn’t understand it. Soon enough, the code needs to be revised following its first release. Sometimes within a month or even a week! Many developers fell into this “rabbit hole”.

Anyone can read a book about software programming and then write executable code to run on the machine. Truth be told, a computer can still execute poorly written code, but not many developers can write human understandable code. Remember that clean code is the key to your software development journey. It will help you and other developers understand the “twists and turns” of your program without unnecessary complexity. Easy to read code means easy to change.

 

Software Maintenance

This means the ability to change any part of the code without negatively affecting another part at any point in time. This is essential to keep up with market needs and compete with the ever-changing software ecosystem.

 

Software Extension

It is the capability to add more functionalities and update any part of the base program without impairing the entire system or another part at any time. Most programs are planned for future expansions to sustain users’ demand in the long run.

 

Software testing

This means the ability to validate the functionality of any part of the program. Testing can be done alone or with a sample group of intended users. Quality assurance is obtained through a series of software testing.

 

Software quality depends on the fulfilment of certain rules and criteria according to specific design principles and patterns. It is more than just doing the job. The rule is to maintain the software functionality, while the criteria are the assessment tools to know whether the entire system functionality or in part, is achieved.

 

Who sets the design principles and patterns?

They are the programming experts who have faced and endured many coding obstacles. They have tried countless solutions and documented their knowledge to write the rules derived from the principles.

It is worth mentioning that most of the design principles and patterns are entirely based on what is known as Object-Oriented-Programming (OOP) such as Object, Inheritance, Polymorphism, Abstraction, Interface, and more.

 

What does SOLID mean?

In 2004, Michael Feathers introduced a pseudonym derived from the 5 software design principles known as:

S – Single Responsibility Principle

O – Open-Closed Principle

L – Pliskova Substitution Principle

I – Interface Segregation Principle

D – Dependency Inversion Principle

 

Responsibility Principle

Think of the code as modules. A module is a part of a program (or code) that can function alone such as procedure, method, class, etc. Responsibility of the module means to perform only the job that module is supposed to do. For example, if there is a class that gets data from the database, we can say that its responsibility is ‘reading data’. If there is a method to check the connection of a database, then we can consider that its responsibility is ‘connection check’.

To understand the Responsibility concept in more detail, let me tell you about Coupling.

Coupling

This means the depth of the relationship between the modules. When the coupling is low, the software will be stronger and easy to maintain. This concept is also known as Loose Coupling.

For example, your program needs to perform a function: to get the employees’ data from the database. We will then have three classes to perform.

  • The data model class contains employees’ identity properties like Id, Name, Phone, Email, etc.
  • The class that will fetch data from the database, we usually call it a Repository.
  • Then the class that will be called from the Application Programming Interface (API), we can call it EmployeeController.

The above three modules have coupling: Controller depends on Repository, and then Repository will need Data Model. To lose this coupling, we will need to use some design patterns like Dependency Injection and Reflection.

Cohesion

This concept is the reverse of coupling.
For example, we need a data model class of the users that will contain properties like Id, Name, Phone, Email, etc. But what if there’s a company Name and Branch as well?

To apply cohesion, the user data model has to contain only user data and create other data model class for company data. Remember, cohesion is the opposite of the coupling concept. It means that the more cohesion among the same class members, the project will be more sustainable, which is essential for software maintenance.

 

Conclusion

Software development and its ecosystem are growing fast. Anyone can read a book about software programming and then write executable code to run on the machine. Although a computer can still execute poorly written code, good developers must write human-readable code. Programmers need to remember the golden rule: that software must be maintainable, extensible, updatable, and testable. Understanding the SOLID principles and “clean code” concept will save programmers from falling into the “rabbit hole” of unnecessary revisions. Remember, successful software endures both the test of quality and the test of time.