I was reading up on abstract factory patternhere, and I am not able to completely grasp its importance.
From what I can understand, it allows programmer to not specify instantiating the specific class. So, if there is a DocumentCreator factory and I need to create my resume then I wouldn't need to do this:
DocumentCreator creator = new ResumeCreator();
Instead I can do this with:
DocumentCreator creator = DocumentCreator.getInstance(resume); (I recall)
Does my understanding on this pattern correct and if it is not could you elaborate on its pros? Why is not specifying the concrete class such a big deal?
Also is the GOF book an easy read for someone newly acquainted with design pattern?
The goal is to separate *what* is being done from *how* it is being done. In other words, the code that uses the Abstract Factory only cares about getting a reference to something that is capable of doing something; how that thing is created is irrelevant. This has to do with the concept of coupling. You want your program components to be loosely coupled as opposed to being tightly coupled. Consider the following code:
The latter declaration of myList is tightly coupled to a specific implementation (ArrayList) whereas the former is not. The former is only concerned with the general behavior as defined by the List interface. This same principle is behind the Abstract Factory pattern. The benefit is that it makes your design/code less brittle/more flexible.
Really appreciate your explaining in plain and simple language. Thanks a bunch! I suppose the static factory is a close cousin of this pattern and understanding this will speed up comprehending the factory method pattern.
I saw that there was no reply to your question "Is the GOF book easy to read?".
Well, of course it depends on what you call "easy to read". The Gof book is strong, but perhaps not the most easy resource for learning about design patterns. The book covers every aspect of the patterns it describes. So it's a very good book if you have already a fair bit of design experience and it can be used as a reference.
I personally prefer Sourcemaking if you want to get a clear overview of the patterns.