Why Do We Use SOLID Principles in C#?


  • The goal of the SOLID principles is to make our code more maintainable and extensible. While this is the ultimate goal, it’s not always the first step we take when starting a new project.

    The SOLID principle are guidelines for writing good code that will be easy to change in the future. These principles are not absolute rules, but rather guides to help us write code that will be easy to maintain.

    SOLID principles are especially important if you have ever worked with someone else’s code or inherited a project from another developer. It can be very difficult to understand what someone else was thinking when they wrote the code, so it’s important that you follow these guidelines in order to make any changes easier if need be in the future.

    1. You should use the Single ResponsibilityPrinciple to break your code into different classes.
    2. You should use Open/Closed Principle to make sure that you can extend your code without having to change it.
    3. You should use Liskov Substitution Principle to make sure that your objects behave as expected when passed around as arguments or returned from methods.
    4. You should use Interface Segregation Principle so that your interfaces are more focused and easier to implement.
    5. You should useDependency Inversion Principle so that you can easily change the implementation of one class without affecting others

إرسال تعليق

Please do not post any spam link in the comment box😊

أحدث أقدم

Blog ads

CodeGuru