Skip to main content

Posts

Showing posts with the label SOLID Principles

SOLID principles in a simple way

The SOLID principles are a set of five design principles that help software developers create more maintainable , flexible , and scalable software systems. These principles were introduced by Robert C. Martin and are widely used in object-oriented programming and software design. Single Responsibility Principle (SRP): A class should have only one reason to change, meaning it should have only one responsibility. In other words, a class should have only one job. Example in C#:                   // Incorrect implementation         class Employee         {             public void CalculateSalary ()             {                 // ... calculate salary logic             }             public void SaveToDatabase ()             {                 // ... save to database logic             }         }         // Correct implementation         class Employee         {             public void CalculateSalary ()             {                 // ... calculate salary logic             }