SOLID

Yiğit Oğuz

26.02.2020

yigitoguz.com

What is OO Design?

Object Oriented Design is the concept that forces programmers to plan out their code in order to have a better flowing program.

Language Consept

  • Encapsulation
  • Data Protection
  • Inheritance
  • Interface
  • Polymorphism

There are five general design principles of object-oriented programming intended to make software more understandable, extendable, maintainable and testable.

What is solid in software development?

  • Single Responsibility Principle
  • Open Closed Principle
  • Liskov Substitution Principle
  • Interface Segregation Principle
  • Dependency Inversion Principle

Single Responsibility Principle

One class should have one and only one responsibility

public class Account
{
    public void ChangeUserName()
    {
        
    }
 
    public void SetAccountActivate()
    {
        
    }
}

Open Closed Principle

Software components should be open for extension, but closed for modification

public class Account
{
    public void ChangeUserName()
    {
        
    }
 
    public void SetAccountActivate()
    {
        
    }
    
    //?
    public void SendEmail()
    {

    }
}

Liskov's Substitution Principle

Derived types must be completely substitutable for their base types

public class Account : AbstractMember
{
   public override void Unsubscribe()
    {
       //TODO:
    }
}


public class Admin : AbstractMember
{
	
   public override void Unsubscribe()
    {
        //?
    }
}

Interface Segregation Principle

Clients should not be forced to implement unnecessary methods which they will not use

public class Account : ICreateNewProduct
{
   public void CreateNewProduct(..)
    {
       throw new NotImplementedException();
    }
}


public class Admin : ICreateNewProduct
{
	
   public void CreateNewProduct(..)
    {
        //TODO
    }
}

Dependency Inversion Principle

Depend on abstractions, not on concretions

Design Patterns

In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design. A design pattern isn't a finished design that can be transformed directly into code. It is a description or template for how to solve a problem that can be used in many different situations.

Made with Slides.com