One to many dependency between objects.
When an object changes state , all its
dependencies are notified and updated.
• Knows the list of investors.
• Provides methods for attaching , detaching and notifying
• Stores the state of interest to observers.
• Notifies observer when state changes.
• Interface for objects that is to be notified with the changes of
• Update the observer with the subject.
• Maintains a reference to the concrete subject object.
• High level module should not depend on low level
modules . Both should depend on abstraction.
• Abstraction should not depend on details . Details
should depend on abstraction.
• A design pattern based on DIP
• Inverting the control so that lower module does not control the interface
and object creation.
• Specialization of IOC.
• Helps to make loosely coupled code.
• Increase extensibility and maintainability.
• The Dependency Injection pattern uses a builder
object to initialize objects and provide the required
dependencies to the object means it allows you to
"inject" a dependency from outside the class.
• The Service Locator pattern introduces a locator
object that objects is used to resolve dependencies
means it allows you to "resolve" a dependency
within a class.