Type of Creational DP.
Singleton Vs Factory.
Singleton always returns you a same object, But factory returns to a new and requested/difference objects.
key-point:
creates objects without exposing the instantiation logic to the client.
refers to the newly created object through a common interface
How it works:
1) Client need a object, Instand of creating using new operator it will ask factory object to give a new Object,
2) The factory instantiates a new concrete product and then returns to the client the newly created product.
3) Client uses the products as abstract products without being aware about their concrete implementation
Singleton Vs Factory.
Singleton always returns you a same object, But factory returns to a new and requested/difference objects.
key-point:
creates objects without exposing the instantiation logic to the client.
refers to the newly created object through a common interface
How it works:
1) Client need a object, Instand of creating using new operator it will ask factory object to give a new Object,
2) The factory instantiates a new concrete product and then returns to the client the newly created product.
3) Client uses the products as abstract products without being aware about their concrete implementation
No comments:
Post a Comment