Misconceptions about design patterns

Why does all Design Patterns looks the same?

The very common questions that is asked by most of my participants during the designs patterns program.

"Hemant all these patterns look the same how do we understand the difference between the same?"

The answer is . they all look the same , because most of them are nothing but level of indirections trying to increase the flexibility of the system by some parameter. That's the only commonality.

As we know level of indirection is the technical tool used to increase the flexibility of any system. We also know that every level of indirection will always hide something [or some aspect of a system].. and hence the flexibility increases by that parameter.

"Level of indirection" is common ..but what the "Level of indirection" hides is different thereby increasing the flexibility by that parameter.

For example

  • Remote Proxy as a level of indirection transparently hides the actual location of the object thereby increasing the flexibility wrt location on an Object.
  • Virtual Proxy as a level of indirection transparently hides the time at which the expensive object gets created thereby increasing the flexibility wrt creation of an Object.
  • Protection Proxy as a level of indirection transparently hides the access control mechanism of an object thereby increasing the flexibility wrt controlling access to an Object.
  • Composite as a level of indirection hides the difference between the whole and the part of a complex system thereby increasing the flexibility of a complex highly nested whole part system.
  • Controller as a level of indirection hides the internal structural and behavioral details of a system there by increasing the structural and behavioral usability, flexibility and security of a system.
  • Mediator as a level of indirection hides the one to one intercommunication between the components of a complex system there by increasing the structural and behavioral flexibility of a system.
  • Adapter as the level of indirection hides the heterogeneity in interfaces of communicating systems there by increasing the flexibility of the system wrt disparate interfaces.
  • Decorator as a level of indirection transparently hides the fact that some another object is decorating the target object with some extra behaviors at runtime thereby increasing the behavioral flexibility within a system.
  • Bridge as a level of indirection hides the implementations of the interface from the client , there by increasing the flexibility of the system wrt implementations of an interface.
  • etc

Like this every design pattern of object scope uses interface / abstract class as a level of indirection hiding certain aspects of a system thereby increasing the flexibility of the system.

 
Hemant Jha
Founder - VPlanSolutions
Researcher, Trainer

www.VPlanSolutions.co.in