Posts

Showing posts from November, 2015

Abstract factory design pattern.

Image
Background - Please read the factory concept or skip if you have a good understanding of it. When you have a requirement to run your product on multiple operating systems (i.e., Windows, RedHat Linux, Mac, Solaris, HPUX, etc.), the only difference is how your object is getting created on different platforms. The business logic and look and feel of the product has to remain the same on all OS. You are creating the same set of objects but for different–different OS families. Here you have to handle the creation part as per OS, yes we are talking about a class whose core behavior is to create objects. Whenever you get such kind of situations where the same set of objects are getting created differently depending upon the family, they belong to. You shall start thinking about abstract factory design pattern. Abstract factory design pattern – It is A class-based design pattern (not object-based). Very important for any product where the designer is looking at portability as o...

Factory concepts.

Background - Read-only background section of Factory method design pattern ( only first half ) for more clarity, before you continue with this article. First of all, what do you understand from word factory? Simple, where we create something. Like we build cars, bikes, PC, mobiles, etc., In factories. Same way, we create software objects in the factory. Factory concept is there to achieve creational flexibility. Factory is not only to create objects but to maintain the population of objects as well.  Why do I need a factory to create my object? There are many benefits of creating objects from the factory instead of from class itself.  Quality assurance - There will be many complex objects you will encounter in your project, which had many dependencies and cannot be created without having some dependent object in hand. If you give freedom to the developers. To create objects from wherever they want in the project, then who will guarantee the quality of a com...

Factory method design pattern for beginners.

Image
Background - First, let me ask a simple question. Do you really think that "factory method design pattern comes because we had an issue with creating objects? Or it is only for creating objects? Or why we need a factory to create an object when we can create it through constructor? The answer is NO! Each class is capable of creating objects on its own. Through constructor (until and unless you have not put constructor in private).  Then why we need factory at all? Is there something like, without Factory method, I am not able to create my software? No, we can create objects without it, then why we are using it very extensively? Remember one thing, programming languages are very powerful . W e can build software without following any design principles. But then, it will be poor in some of these areas -  Maintainability. Extend-ability. Performance. Security. Robust. and many more... Developers have been developing...