Friday, March 25, 2011

Design pattern interview questions :- Which design patterns have you used in your project ?


First thing what ever you say , for heaven sake do not say we had used all design patterns ;-) . Look at your project and see which design pattern have you used. Almost all projects use design patterns knowingly or unknowingly , until the project is complete disorganized.

While explaining do ensure to make a 1 line comment atleast to say why that design pattern was used.

Below goes a decent answer of explaining things collectively. Please note answer will change as per your project implementation.

In my current project we had used MVC, Singleton, factory , iterator and template pattern.

My project was tier architecture, divided in to 3 main sections, UI, Business layer and data access layer.

At the presentation level we had used MVC pattern, so the UI and model was separated using controller class.

To share common data across all tiers we had used the singleton pattern.

Factory classes where used between each layer for decoupling and centralizing object creation to avoid code complication.

Iterator pattern was used to browse through middle tier objects thus providing a tight encapsulation.

The middle tier objects and their child objects where standardized using template pattern for consistent vocabulary and naming convention for business objects.

Watch the below design pattern video which explains factory pattern.


Please click here to see .NET interview questions and J2EE design pattern questions