The open/closed principle (OCP) states that a module should be open to extension but closed for modification. It is one of famous 5 solid principles and very important object oriented design principle. 1. Definition of open closed principle There are two popular definitions to describe this principle – 1.1. The Meyer definition Bertrand Mayer, in […]
The single responsibility principle (SRP) states that a software component (in general, a class) must have only one responsibility. The fact that the class has a sole responsibility means that it is in charge of doing just one concrete thing, and as a consequence of that, we can conclude that it must have only one reason to change. It is one of 5 famous SOLID principles.
The state pattern is a behavioral design pattern. According to GoF definition, a state allows an object to alter its behavior when its internal state changes. The object will appear to change its class. It can be drawn from above definition that there shall be a separate concrete class per possible state of an object. […]
Mediator helps in establishing loosely coupled communication between objects and helps in reducing the direct references to each other.
According to GoF definition, observer pattern defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically. It is also referred to as the publish-subscribe pattern. In observer pattern, there are many observers (subscriber objects) that are observing a particular subject (publisher object). Observers register […]