Posts

Showing posts from June, 2017

Observar Design Pattern

Image
This is a behavioural pattern. The observer pattern is a design pattern that defines a link between objects so that when one object's state changes, all dependent objects are updated automatically. 1. Suppose there are three users Anil,Prashant and Asha. All three wants to purchase same product  book which is not in stock on E-Commerce website. 2. So all our three users used a Notify option given by E-Commerce website. In this case website should notify a users when the product will be available. Implementation: There are 2 basic class in observer design pattern 1. Subject  2. Observer Subject: The main responsiblilty of this class is to maintain the user list and update all subscribed users if any change happen .     vector<Users*> userlist;     void Attach(Users *user);     void Detach(Users *user);     void Notify(bool isavailable); O...