DEV Community

Gias Uddin
Gias Uddin

Posted on

4 Principles Of Software Engineering That Every Engineer Should Know

In software development, it is important to adhere to principles and guidelines that help to create code that is maintainable, flexible, and easy to understand. Some of the key principles that software developers should consider include dry (Don't Repeat Yourself), solid (Single Responsibility Principle), kiss (Keep It Simple, Stupid), and lod (Low of Demeter). These principles help developers to create code that is more modular, less complex, and easier to maintain, which can improve the overall quality of the software. In this article, we will delve deeper into these principles and discuss how they can be applied in the software development process.

1. Dry (Don't Repeat Yourself): The principle of dry suggests that developers should strive to eliminate redundancy in their code. This means avoiding duplication of information and functionality in different parts of the codebase. By adhering to this principle, developers can reduce the complexity of the software and make it easier to maintain.
For example, if a developer needs to perform a specific action in multiple parts of the code, they should create a function or method that encapsulates that action and call it whenever it is needed. This avoids the need to duplicate the same code in multiple places, which can make it difficult to update or modify the software in the future.

2.Solid (Single Responsibility Principle): The solid principle states that each component or class in a software system should have a single, well-defined responsibility. This helps to reduce complexity and improve the modularity of the software. By adhering to this principle, developers can create more flexible and reusable code that is easier to maintain and debug.
For example, if a developer is creating a class to handle data validation, they should focus on creating a class that performs that specific task and does not contain any additional functionality. This allows the class to be used in multiple parts of the codebase without introducing unnecessary complexity.

3.Kiss (Keep It Simple, Stupid): The kiss principle advocates for simplicity in software design, suggesting that the most straightforward solution is often the best. This helps to reduce complexity and improve the maintainability of the software. By adhering to this principle, developers can create code that is easier to understand and debug, which can save time and resources in the long run.
For example, if a developer is faced with multiple solutions to a problem, they should choose the one that is the most straightforward and easy to understand. This may not always be the most efficient solution, but it can be easier to maintain in the long term.

4.Lod (Low of Demeter): The lod principle states that a component should only communicate with its immediate neighbors and should not have knowledge of the inner workings of other components. This helps to reduce dependencies and improve the modularity of the software. By adhering to this principle, developers can create code that is more flexible and easier to maintain.
For example, if a developer is working on a class that needs to access data from another class, they should not directly access the data. Instead, they should create a method in the other class that returns the data, allowing them to access it without having knowledge of the inner workings of that class. This reduces the dependencies between the two classes and makes the code more flexible and easier to maintain.

In conclusion, the principles of dry, solid, kiss, and lod are important guidelines for software development that help developers create code that is maintainable, flexible, and easy to understand. By following these principles, developers can create software that is easier to update and modify, which can save time and resources in the long run. By adhering to these principles, developers can create software that is more robust and reliable, which can improve the user experience and the overall quality of the software.

Thank you for reading my article! If you enjoyed it and would like to support my work, please consider buying me a coffee at Buy Me a Coffee. You can also learn more about me and my work by visiting my Giasuddin Bio and following me on LinkedIn and Twitter. Thank you for your support!

Top comments (2)

Collapse
 
tracygjg profile image
Tracy Gilmore • Edited

Hi Gias,
SOLID is actually a group of principles with the SRP (Single Responsibility Principle) being just the first. The others include:
O — Open closed principle
L — Liskov substitution principle
I — Interface segregation principle
D — Dependency Inversion principle

But you know this.

Regard.

Collapse
 
htho profile image
Hauke T.

Good article.

A note on LOD:
Data structures/objects are an exception from this. If you have a Json configuration object, there is no need to create objects with methods to expose those parameters. This would not be kiss, but just a lot of boiler plate code.