Basic design principles in c# are SOLID design principles. In Object-Oriented Programming (OOP), Michael Feathers introduced the acronym SOLID. These five design principles are very useful to make software design more maintainable, understandable, and flexible. Robert C. Martin promoted many design principles, and SOLID principles are a subset of those principles. By using these principles in our application design, we can achieve the desired results by loosely coupling and encapsulating the real needs of a business properly and can avoid tightly coupled code and little encapsulation.
There are five SOLID principles:
- S: Single Responsibility Principle (SRP): SRP says “Every software module should have only one reason to change”. This principle says that every class should have only one task. Do not have more than one functionality in one class.
- O: Open-Closed Principle (OCP): The Open/Closed Principle says, “A software module/class is open for extension and closed for modification.” “Open for extension” means that our module or class should be designed in such a way that if in the future there is a need to add any new functionality, we can easily add it to the application. “Closed for modification” means if we are adding new functionality, we have no need to change the old classes. They are already tested and are closed now.
- L: Liskov Substitution Principle (LSP): The Liskov Substitution Principle (LSP) says “you should be able to use any derived class instead of a parent class and have it behave in the same manner without modification”. With this, we ensure that we will not change the behavior of the base class with any modifications in the derived class. In other words, we can always substitute a derived class with a base class.
- I: Interface Segregation Principle (ISP): The Interface Segregation Principle says “that clients should not be forced to implement interfaces they don’t use.” Instead of one fat Many small interfaces are preferred based on groups of methods, each one serving one submodule. ” We can define it in another way. An interface should be made in a way that closely meets the requirements of the client. Do not include any unnecessary methods in it.
- D: Dependency Inversion Principle (DIP): The Dependency Inversion Principle (DIP) states that high-level modules/classes should not depend on low-level modules/classes. They should depend on abstractions.
Advantages of using SOLID principles:
- With this, maintenance of the software application becomes easy and the software will accept modifications to the future requirements easily.
- Since it will be loosely coupled, we can test our application efficiently, and it is important to test every module of the project as its size grows.
- Applications will become more flexible and scalable.
- We can develop the modules in parallel as they will be loosely coupled, and it is very important for a project to be completed on time.
Disadvantages of not using SOLID principles:
- Classes can be stressed by adding more functionalities together which are not related to each other.
- Classes will become dependent on each other and will be tightly coupled. So, in the future, a change in one class will affect every other dependent class.
- There can be duplicate and redundant code in the application.
People having good knowledge of Financial accounting can get an accounting certification from StudySection to increase their chances of getting a job in this field. You can get a foundation level certification if you are new to Financial Accounting or you can go for advanced level certification if you have expert level skills in Financial accounting.