Adapter Pattern

This post is about the Adapter Pattern. Like the Decorator Pattern this one is also a Structural pattern.

What this patterns does is it allows the client to use different types of classes throughcommon adapter. These classes are called adaptee and they don’t have to change in any way to conform to our client.

Instead, an adapter is created to, well, adapt (no pun intended) to our client objectives.

Continue reading Adapter Pattern

Interface Segregation Principle

The I in SOLID is for Interface Segregation Principle (ISP).

This is the fourth principle, and it’s a very easy one to understand, it’s all about decoupling your classes and extensions. The intent is that:

Clients should not be forced to depend upon interfaces that they don’t use.

Continue reading Interface Segregation Principle

Single Responsibility Principle

This is my first post of the SOLID principle series. SOLID stands for:

  • Single Responsibility Principle
  • Open and Close Principle
  • Liskov’s Substitution Principle
  • Interface Segregation Principle
  • Dependency Inversion Principle

So what’s a design principle and what do we use it for ?

Very roughly, they are guidelines that a developer can follow to avoid choosing a bad design. These principles allows us to write better code that avoid rigidity, fragility and immobility. Rigidity is when your code is too tied to other parts of the system. Fragility is when your code changes can break other parts of the system. Immobility occurs when the code is to hard to port to a different project because it lacks versatility and adaptability.

Continue reading Single Responsibility Principle