In this video we will discuss
1. What is Single Responsibility
2. Single Responsibility Example
In our previous video we discussed S in the SOLID is acronym for Single Responsibility Principle (SRP)
As per the single responsibility principle
1. A class should have only one reason to change
2. Which means, every module or class should have responsibility over a single part of the functionality provided by the software, and that responsibility should be entirely encapsulated by the class.
Encapsulation is one of the fundamentals of OOP. At this moment, understanding more about encapsulation is out of scope of this session. However, we strongly recommend you to refer to the C# tutorial playlist for more details on Object oriented principles. Now you might be wondering what do we achieve with the Single Responsibility Principle or rather with the SOLID Design Principles.
Let's first understand the motivation behind the usage of SOLID Principles
In any enterprise software application development when we design and develop software systems, we need to account the below factors during the development cycle.
Maintainability : Maintainable systems are very important to the organisations.
Testability : Test driven development (TDD) is required when we design and develop large scale systems
Flexibility and Extensibility : Flexibility and extensibility is a very much desirable factor of enterprise applications.Hence we should design the application to make it flexible so that it can be adapt to work in different ways and extensible so that we can add new features easily.
Parallel Development : It is one of the key features in the application development as it is not practical to have the entire development team working simultaneously on the same feature or component.
Loose Coupling : We can address many of the requirements listed above by ensuring that our design results in an application that loosely couples many parts that makes up the application.
SOLID Principles and Design Patterns plays a key role in achieving all of the above points.
In Single Responsibility Principle
1. Each class and module should focus on a single task at a time
2. Everything in the class should be related to that single purpose
3. There can be many members in the class as long as they related to the single responsibility
4. With SRP, classes become smaller and cleaner
5. Code is less fragile
Hence we can say that Single Responsibility Principle achieves the motivation points that we have just discussed.
Below code demonstrates how we can achieve Single Responsibility Principle
Code before Single Responsibility Segregation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SRPDemo
{ interface IUser { bool Login(string username, string password); bool Register(string username, string password, string email); void LogError(string error); bool SendEmail(string emailContent); }
}
Code after Single Responsibility Segregation
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SRPDemo
{ interface IUser { bool Login(string username, string password); bool Register(string username, string password, string email); } interface ILogger { void LogError(string error); } interface IEmail { bool SendEmail(string emailContent); }
}
Now that we have segregated the single responsibility principle in these multiple interfaces the next step is to implement these interfaces with object creation mechanisms. GOF has defined many design patterns on object creations based on the requirements.
Hence we strongly recommend you to refer to our design pattern tutorial for more details on creational design patterns.
I believe this session has given you a good idea on how we can implement Single responsibility principle.
In the next video we will discuss Interface Segregation Principle.
Text version of the video
http://csharp-video-tutorials.blogspo...
Slides
http://csharp-video-tutorials.blogspo...
SOLID Design Principles Tutorial
https://www.youtube.com/watch?v=HLFbe...
SOLID Design Principles Text Articles & Slides
http://csharp-video-tutorials.blogspo...
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenka...
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatAr...
asp.net core docker Single Responsibility Principle | |
| 430 Likes | 430 Dislikes |
| 92,714 views views | 524K followers |
| Science & Technology | Upload TimePublished on 27 Nov 2017 |
Related keywords
tutorialspoint,csharp-video-tutorials.blogspot,webkinz,tutorials dojo,csharp string format,central park 5,webadvisor,asp.net core github,craigslist nj,asp.net core 3,server status,server jobs nyc,asp.net core swagger,weber grill parts,credit karma,services group,webtoon,tutorials by hugo,csharp corner,asp.net machine account,server error in '/' application,servers for minecraft,asp.net core dependency injection,services windows,asp.net core 3.0,tutorialspoint c#,services angular,calculator,tutorialspoint tableau,services google play apk,asp.net mvc tutorial,asp.net core 3 release date,server job description,tutorials by a,asp.net cos'è,servicenow,csharp assembly,webcam,webmd symptom,csharp array,tutorialspoint python,services briefcase,asp.net core web api,csharp enum,craigslist ny,asp.net core 2. guida completa per lo sviluppatore,asp.net core,server pro,server status ffxiv,asp.net zero,csharp foreach,webcrims,cheap flights,server memes,asp.net core hosting,services sas,services online,chase,tutorialspoint java,serverless architecture,tutorialspoint java compiler,server resume,server books,tutorialspoint javascript,webmd,services technologies gps,csharp to json,college football,csharp dictionary,server jobs,cvs,website,cnn,website builder,costco hours,tutorialspoint sql,asp.net web api,server side rendering,weber grills,tutorialspoint spring,serverless,tutorialspoint spark,asp.net core download,csharp to vb.net,cool math games,webster bank,services & training hse colombia sas,servicestack,citibank,asp.net core identity,webstaurant,asp.net core logging,tutorialsystems,asp.net guida,cunyfirst,csharp download,services fms publish announcement,services.msc no abre,csharp online,csharp operator,asp.net core razor pages,server duties,asp.net core environment variables,tutorials near me,csharp random,http://asp.net,server 2019,web of dreams,chernobyl,century 21,serverminer,webassign,services consultores,services consulting,services.msc,asp.net core configuration,csharp list,asp.net tutorial,asp.net mvc,asp.net core tutorial,asp.net core mvc,server hosting,chase online,costco,server jobs near me,webex,capital one,server rack,tutorialspoint html,csharp interface,craigslist,tutorialsteacher,webroot,tutorialspoint reactjs,asp.net core 2.2,services desk,tutorialspoint python 3,webster,services transmission company sas,asp.net core signalr,services manager,csharp tutorial,asp.net identity,tutorialspoint spring boot,asp.net core middleware,csharp online compiler,asp.net download,services tag dell,csharp switch,web store,webmail,csharpstar,
Không có nhận xét nào:
Đăng nhận xét