#oops Basic

  1. You cannot extend or inherit more than 1 abstract class (C# does not provides multiple inheritance.)
  2. Struct cannot implement an abstract class.
  3. Struct can implement interfaces.

class MyClass : a,b ---ERROR--Cannot implement multiple base class.


abstract class a


abstract class b


#Interfaces VS Abstract Class

Abstract class gives you all the benefits that interfaces does,except very  important one feature “Multiple Inheritance“. This is the sole reason why we are asked to write “program to an interface”.You would argue that i would load a constructor with a abstract class rather than interface,but it would fail since you cannot implement more than one class and you need interface to do that.Capture

#50-SOLID -Liskov Substitution Principle

Liskov Substitution Principle: SubType (Child Class)Must be Substitutable For Base Type(Base Class).

LSP comes into use when you use inheritance/Abstraction.


1.Child Class Should not remove Base Class Behaviour.

2.Child Class Should not violate base class invariants.

In short,the Calling code should not know whether it is calling the base class or derived class.

#3 Decorator Pattern

When to Use Decorator Pattern?

Add New Responsibility(functionality) to the class,without breaking the existing functionality.


1.Component as abstract class/Interface.

2.Concrete Components Implementing the Components.

3.Decorator as abstract class/Interface with Component as member initialized via constructor.

4.Concrete Decorator Implements Decorator.

Functionality are added at runtime,Hard to debug(Since object implements both Concrete Component and Concrete Decorator).

 Source Code:https://github.com/rangesh-/Design-Patterns/tree/master/Design%20Patterns/Decorartor%20Pattern