Shailendra kumar shail @ AVACorp.biz
Design Pattern in Java
Abstract: “Pattern” as the name suggests, means series of events occurring in a definite order. The patterns can be found in Java and J2ee technologies also. Many a times, we find that there is a particular way of tackling a problem. This way is easy and has been used many times successfully by a number of people earlier also. This method becomes a pattern.Learning the design patterns is a multiple step process:
· Acceptance
· Recognition
· Internalization
“Design patterns are recurring solutions to design problems.”Patterns: According to commonly known practices, there are 23 design patterns in Java. These patterns are grouped under 3 heads:
1. Creational Patterns
1. Creational Patterns
· Factory
· Abstract Factory
· Singleton
· Builder
· Prototype
2. Structural Patterns
· Adapter
· Bridge
· Composite
· Decorator
· Façade
· Flyweight
· Proxy
3. Behavioral Patterns· Chain of Responsibility
· Command
· Interpreter
· Iterator
· Mediator
· Momento
· Observer
· State
· Strategy
· Template
· Visitor
This topic about patterns makes me wonder about a scenario...
ReplyDeleteLet's say, there are many DAO's that I've written. Now, I use the Factory pattern to create instances of them. Also, assume that its a multiuse web app. So, does it make sense to make it singleton ???
I think you are trying to mingle two patterns for multiuse web application. Choosing a design pattern depends upon type of project. Can you clarify that whether you want to use Factory Patter or Singleton Patter?
ReplyDeleteThough you take a example to multiuse web application, you can make use of Singleton Pattern. There are many web applications use Spring framework, and you know one of the advantage of Spring is Singleton.
In case of DAO's you can create individual Singleton class for each DOA or Spring Framework (IOC) can be used to maintain this. (Remember, Here i am not talking about factory pattern)