Design Patterns
1. What are design patterns? Why use them?
2. Which design patterns have you used? How?
3. What is the difference between factory, abstract factory?
4. What is builder design pattern?
5. What is singleton? Why use it? Singleton vs static? Write code for singleton.
6. What is observer design pattern? Write code.
7. Which design patter stringbuilder uses?
*************ANSWERS*************
1. What are design patterns? Why use them?
Design patterns are time tested solutions to the commonly occuring problems.
Using design patterns can save us from a lot of issues and improve the performance,longevity, development time of project.
Design patterns are time tested solutions to the commonly occuring problems.
Using design patterns can save us from a lot of issues and improve the performance,longevity, development time of project.
2. Which design patterns have you used? How?
I have used Singleton, Factory, Observer, State, Composite, MVC, Front Controller.
Singleton in hibernate, spring, util classes. (my own singleton?)
Factory in feeders and adapters. (will give detail later)
Observer in callhome and updating state.
State to change the state of platform.
Composite in building the mainframe heirarchy.
MVC in liferay and spring.
Front Controller in spring, feeders and adapters(?)
I have used Singleton, Factory, Observer, State, Composite, MVC, Front Controller.
Singleton in hibernate, spring, util classes. (my own singleton?)
Factory in feeders and adapters. (will give detail later)
Observer in callhome and updating state.
State to change the state of platform.
Composite in building the mainframe heirarchy.
MVC in liferay and spring.
Front Controller in spring, feeders and adapters(?)
3. What is the difference between factory, abstract factory?
Abstract factory is one more layer over factory, it contains a factory of factories which is then further used to get an object.
Abstract factory is one more layer over factory, it contains a factory of factories which is then further used to get an object.
4. What is builder design pattern?
When the number of arguments are a lot builder design pattern can be used. Builder design pattern builds an object in a series of steps. It is very useful if the object contains some mandatory arguments and some optional arguments. The mandatory arguments can be set in the constructor and optinal arguments can by set via setter methods.
When the number of arguments are a lot builder design pattern can be used. Builder design pattern builds an object in a series of steps. It is very useful if the object contains some mandatory arguments and some optional arguments. The mandatory arguments can be set in the constructor and optinal arguments can by set via setter methods.
5. What is singleton? Why use it? Singleton vs static? Write code for singleton.
Singleton maintains a single object of the class. It is used when a single resource is shared by all the objects e.g, System, Runtime or if an object creation is very costly e.g, Hibernate SessionFactory, ConnectionPool,etc.
Singleton vs static?
6. What is observer design pattern? Write code.
Observer design pattern is used when there are multiple objects observing the state of an object. In this the subject maintains a list of observers who are notified in case the subject changes it state, the observers then get the state of the subject.
Singleton maintains a single object of the class. It is used when a single resource is shared by all the objects e.g, System, Runtime or if an object creation is very costly e.g, Hibernate SessionFactory, ConnectionPool,etc.
Singleton vs static?
6. What is observer design pattern? Write code.
Observer design pattern is used when there are multiple objects observing the state of an object. In this the subject maintains a list of observers who are notified in case the subject changes it state, the observers then get the state of the subject.
7. Which design patter stringbuilder uses?
Builder pattern.
Builder pattern.
9. What is MVC and n tier ? Why use it ? Difference
4. Difference between strategy and state?
4. Difference between strategy and state?
No comments:
Post a Comment