Single Responsibility Principle
Hellow guys, Welcome to my website, and you are watching Single Responsibility Principle. and this vIdeo is uploaded by kudvenkat at 2017-11-27T12:34:34-08:00. We are pramote this video only for entertainment and educational perpose only. So, I hop you like our website.
Info About This Video
Name |
Single Responsibility Principle |
Video Uploader |
Video From kudvenkat |
Upload Date |
This Video Uploaded At 27-11-2017 20:34:34 |
Video Discription |
In this video we will discuss
1. What is Single Responsibility
2. Single Responsibility Example
Healthy diet is very important both for the body and mind. If you like Aarvi Kitchen recipes, please support by sharing, subscribing and liking our YouTube channel. Hope you can help.
https://www.youtube.com/channel/UC7sEwIXM_YfAMyonQCrGfWA/?sub_confirmation=1
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.
In the next video we will discuss Interface Segregation Principle.
Text version of the video
http://csharp-video-tutorials.blogspot.com/2017/11/single-responsibility-principle.html
Slides
http://csharp-video-tutorials.blogspot.com/2017/11/single-responsibility-principle-slides.html
SOLID Design Principles Tutorial
https://www.youtube.com/watch?v=HLFbeC78YlU&list=PL6n9fhu94yhXjG1w2blMXUzyDrZ_eyOme
SOLID Design Principles Text Articles & Slides
http://csharp-video-tutorials.blogspot.com/2018/01/solid-design-principles.html
All Dot Net and SQL Server Tutorials in English
https://www.youtube.com/user/kudvenkat/playlists?view=1&sort=dd
All Dot Net and SQL Server Tutorials in Arabic
https://www.youtube.com/c/KudvenkatArabic/playlists |
Category |
Science & Technology |
Tags |
solid principles | solid principles c# | solid principles of object oriented design | solid design principles c# | solid design principles | solid design principles video | what are solid principles | single responsibility principle | single responsibility principle c# | Learning SOLID Principles Using C# | design principles |
More Videos