Skip to main content

Posts

Showing posts from October, 2016

Design Patterns (aka DP), Creational - Abstract Factory Pattern

DP is a well-described solution to a common software problem. Its benefits: Already defined to solve a problem. Increase code reusability and robustness. Faster devlopment and new developers in team can understand it easily DP defined in to 3 categories: Creational  - Used to construct objects such that they can be decoupled from their implementing system. Structural  - Used to form large object structures between many disparate objects Behavioral  - Used to manage algorithms, relationships, and responsibilities between objects. Creational : Abstract Factory :- In short we call it Factory of Factories. To understand this please read factory pattern . When you go through factory pattern: You see that factory can produce only Computers or aptly varied types of Computers. But only Computers. Now, Say you have a 3rd variety of Computer just like PC or Server. Say, Laptop class. You can easily inherit Computer an create your Laptops. So...

Design Patterns (aka DP), Creational - Factory Pattern

DP is a well-described solution to a common software problem. Its benefits: Already defined to solve a problem. Increase code reusability and robustness. Faster devlopment and new developers in team can understand it easily DP defined in to 3 categories: Creational  - Used to construct objects such that they can be decoupled from their implementing system. Structural  - Used to form large object structures between many disparate objects Behavioral  - Used to manage algorithms, relationships, and responsibilities between objects. Creational : Factory  - Exposes a method for creating objects, allowing sub-classes to control the actual creation process. Consider a scenario as below:- You have an interface or abstract class or a normal class. Computer class There are 2 sub-classes of of Computer. PC class and Server class Now you have a factory which provides you Computers. And you can give specification to factory whether you ...