Showing posts with label SOLID Principles. Show all posts
Showing posts with label SOLID Principles. Show all posts

Tuesday, September 1, 2015

SOLID Principles

SOLID is an acronym for basic object oriented programming & design principals. Applying these principle on system makes system easy to maintain and extendable with time.
  • Single Responsibility Principle (SRP)
  • Open Closed Principle (OCP)
  • Liskov Substitution Principle (LSP)
  • Interface Segregation Principle (ISP)
  • Dependency Inversion Principle (DIP) 
Also refer nice article on https://www.syncfusion.com/blogs/post/mastering-solid-principles-csharp 
  • Single Responsibility Principle (SRP): Single responsibility principle says a software module / class should have only one reason to modify. It means if any class having more than one reasons to modify, this is violation of SRP.
    public class Circle
    {
        private int _radius;
        public int Radius
        {
            get
            {
                return _radius;
            }
            set
            {
                value = _radius;
            }
        }

        public int Area()
        {
            return Radius * Radius * 22 / 7;
        }

        public string PrintHTMLArea()
        {
            return "<h2>" + Area().ToString() + "</h2>";
        }
    }

Above class contains two responsibility
Calculating Area
Printing Area

If properties need to add/modify or print method need to be modified or need to add new print method, class need to be updated. So this is violation of SRP, entity class should have only entity specific things like variables / properties.

CI/CD - Safe DB Changes/Migrations

Safe DB Migrations means updating your database schema without breaking the running application and without downtime . In real systems (A...