Skip to main content

S.O.L.I.D Design Principles

Hold on!!! Before this please read the common design principle post.

After a long time thought of writing a post. Actually these days I'm reading a book which is written by Scott Millet and the name of the book is "Professional ASP.Net Design Patterns". I can guarantee that this book give you a great knowledge on design stuffs.

Most of us are bit lazy to read things, so I thought of posting the things that I got form it. This is like the cream of what I got.

I'll start it with the S.O.L.I.D design principles:

The term S.O.L.I.D. comes from the initial letter of each of the five principles that were collected in the book Agile Principles, Patterns, and Practices in C# by Robert C. Martin, or Uncle Bob to his friends. Simply this is a collection of best practices for object-oriented design.

Following will explain all the principles:

Single Responsibility Principle (SRP)
This principle is closely aligned with a common design principle called Separation of Concerns. It says that every object should have one reason to change and single focus of responsibility. By applying this principle, you avoid the problem of monolithic class design. At the same time this principle gives readability and maintenance for a system.

Open-Closed Principle (OCP)
This principle says that classes should be open for extension and closed for modification, in that you should be able to add features and extend a class without it changing its internal behavior. In other words it avoids the possibilities of braking the system.

Liskov Substitution Principe (LSP)
The LSP says that you should be able to use any derived class in place of a base class and have it behave in the same manner without modification. In other words derived classes must be substitutable for their base classes.

Interface Segregation Principle (ISP)
The ISP is all about splitting the methods of a contract into groups of responsibility and assigning
interfaces to these groups to prevent a client from needing to implement one large interface and a host of methods that they do not use. The purpose behind this is so that classes wanting to use the same interfaces only need to implement a specific set of methods as opposed to a monolithic interface of methods.

Dependency Inversion Principle (DIP)
The DIP is all about isolating your classes from concrete implementations and having them depend on abstract classes or interfaces. It promotes the mantra of coding to an interface rather than an implementation, which increases flexibility within a system by ensuring you are not tightly coupled to one implementation.

This is about the S.O.L.I.D design principles. I hope this will you guys on the long way of design someday.

This is the first one of a series of articles. I'll be back with design patterns.

Comments

Popular posts from this blog

Exit a T-SQL Cursor When Condition is met

Have you ever wanted to exit from a cursor when a condition is met? I wanted to do it. So this is how I did it. DECLARE @Field1 AS INT DECLARE @Field2 AS INT DECLARE CursorName CURSOR READ_ONLY FOR SELECT Field1, Field2 FROM TableName OPEN CursorName FETCH NEXT FROM CursorName INTO @Field1, @Field2 WHILE @@FETCH_STATUS = 0 BEGIN IF @Field1 = 1 BEGIN GOTO ENDCURSOR END FETCH NEXT FROM CursorName INTO @Field1, @Field2 END ENDCURSOR: CLOSE CursorName DEALLOCATE CursorName I have set my fonts to bold where you want to notice. So that's all I hope you will get something out of it and it is true that this is not a big deal. :)

Step by step guide to fix Angular app refresh issue in IIS

If you deploy your Angular app in IIS, routing will be handled from the client. So when you refresh a page it will give you 404 error. To get ride of the above-mentioned situation we have to follow the steps as follows: Before deploying anything on IIS, you have to install the URL Rewriting module on the IIS server. Please refer the link. After the installation, you should be seeing the following icon. If you are above to deploy an Angular app when is developed with ASP.Net Core. That deployment steps are explained in my previous blog post . That blog spot explains one issue I came across when I was deploying Angular 7 App with ASP.Net Core in IIS. So now we are done with IIS side installation next, we have to check the deployment files. You have to make sure that web.config file. web.config should contain the followings: <?xml version=”1.0" encoding=”UTF-8"?> <configuration> <system.webServer> <rewrite> <rules>

Generic Repository with Entity Framework Core

Recently I worked on a project with ASP.NET Core which uses Entity Framework Core. With them, I used a generic repository pattern in the data layer. Repository interface was like below: using System; using System.Collections.Generic; using System.Linq.Expressions; using OnlineSurvey.Models; namespace OnlineSurvey.Data { public interface IRepository<T> where T : BaseEntity { T GetById(int id, params Expression<Func<T, object>>[] includExpressions); void Add(T entity); void Delete(T entity); void Delete(int id); IEnumerable<T> GetAll(params Expression<Func<T, object>>[] includExpressions); IEnumerable<T> Find(Expression<Func<T, bool>> where); int Count(); } } And the implementation was like below: using System; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Collections.Generic; using Syste