You can consider these functionalities or features as responsibilities. For example, if you are developing an e-commerce application, then that application may have many features or functionalities such as Registering users, providing login functionality, displaying the product list, allowing the user to place an order, Providing Payment Functionality, Shipping the Order, Billing the Order, Logging the Order Information for Auditing and for Security purpose, sending the Order Invoice to the customer, etc. What is Responsibility?Īn application can have many functionalities (features). Before Proceeding further and understanding the Single Responsibility Principle, first we need to understand What is Responsibility. So, with the help of SRP in C#, the classes become smaller and cleaner and thus easier to maintain. That does not mean your class should contain only one method or property, you can have multiple members (methods or properties) as long as they are related to a single responsibility or functionality. So we need to design the software in such a way that everything in a class or module should be related to a single responsibility. In other words, we can say that each module or class should have only one responsibility to do. The Single Responsibility Principle in C# states that “ Each software module or class should have only one reason to change“. What is the Single Responsibility Principle in C#? Problems of not following the Single Responsibility Principle. Example without using the Single Responsibility Principle.How can we achieve the Single Responsibility Principle in C#?.What is the Single Responsibility Principle in C#?.As part of this article, we are going to discuss the following pointers in detail. The letter S in S OLID stands for the Single Responsibility Principle which is also known as SRP. Please read our previous article before proceeding to this article where we discussed the basics of the SOLID Design Principle in C#. In this article, I am going to discuss the Single Responsibility Principle in C# with Examples. Data Structures and Algorithms Tutorialsīack to: SOLID Design Principles in C# Single Responsibility Principle in C# with Examples.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |