SlideShare una empresa de Scribd logo
1 de 4
Articles from Jinal Desai .NET
Basic Design Patterns Interview Questions
2013-06-01 05:06:51 Jinal Desai
1. What is Design Patterns?
Ans. Design patterns are time tested reusable design solutions to recurring
problems in application development.
2. What is Gang of Four in design patterns?
Ans. The Gang of Four are the four authors of the book, “Design Patterns: Elements
of Reusable Object-Oriented Software”. The four authors were Erich Gamma,
Richard Helm, Ralph Johnson and John Vlissides. The Gand of Four(GoF)
terminology refers to the book or either author in design pattern. GoF patterns are
generally considered foundation for all other patterns.
3. How many total patterns are there in GoF?
Ans. There are total 23 patterns in GoF.
4. What are the categories design patterns divided into?
Ans. There are total three categories into which design patterns divided.
Creational Pattern:Creational patterns provide ways to instantiate single objects or
group of related objects.
Structural Patterns:Structural patterns provide a way to define relationship
between classes and objects.
Behavioral Patterns:Behavioral patterns define ways of communication between
classes and objects.
5. Can you give name of patterns fall in each category?
Ans. Five patterns fall under creational pattern.
Abstract Factory
Factory
Factory Method
Prototype
Singleton
Seven patterns fall under structural pattern.
Adapter
Bridge
Composite
Decorator
Façade
Flyweight
Proxy
Eleven patterns fall under behavioral pattern.
Chain of Responsibility
Command
Interpreter
Iterator
Mediator
Memento
Observer
State
Strategy
Template Method
Visitor
6. What are object patterns?
Ans. Object patterns deals with object relationships that can be changed at runtime.
It specify the relationships between objects. The purpose of object pattern is to allow
the instances of different classes to be used in the same place in a pattern.
Object patterns avoid fixing the class that accomplishes a given task at compile
time.
Instead the actual class of the object can be chosen at runtime. Object patterns
mostly use object composition to establish relationships between objects.
7. What are class patterns?
Ans. Class patterns deals with class relationships that can be changed at compile
time. It specify relationship between classes and their subclasses.
Thus, class patterns tend to use inheritance to establish relationships.
Unlike object patterns and object relationships, class patterns generally fix the
relationship at compile time.
They are less flexible and dynamic and less suited to polymorphic approaches.
8. What is class scope in class patterns?
Ans. Class scope in class patterns is defined at design(compile) time. Class scope
is built in the structure and relationship of classes.
9. What is object scope in object patterns?
Ans. Object scope in object patterns is defined at runtime. Object scope is based
on the relationship of objects(mostly object composition).
10. Can you list down different class patterns and object patterns?
Ans.
Class Patterns
Adapter
Factory Method
Interpreter
Template Method
Object Patterns
Abstract Factory
Builder
Bridge
Chain of Responsibility
Command
Composition
Decorator
Façade
Flyweight
Iterator
Mediator
Memento
Observer
Prototype
Proxy
Singleton
State
Strategy
Visitor
Following is reference table for distribution of design patterns into Class or Object
Patterns and categories of patterns(Creational, Structural and Behavioral).
Purpose
Creational Structural Behavioral
Scope
Class Factory Method Adapter
Interpreter
Template Method
Object
Abstract Factory
Builder
Prototype
Singleton
Bridge
Composite
Decorator
Facade
Flyweight
Proxy
Chain of Responsibility
Command
Iterator
Mediator
Memento
Flyweight
Observer
State
Strategy
Visitor
11. Can you describe all five creational patterns in one line? (Interviewer will
not ask for all five, only one or two)
Ans.
Abstract Factory pattern is used to provide a client with set of “family” of objects
created by the factory which is determined at runtime.
Builder pattern is used to create complex objects with internal parts that must be
created in the same order or using a specific algorithm.
Factory Method pattern is used to replace class constructors, abstracting the
process of object generation in a way that the type of object instantiated can be
determined at runtime.
Prototype pattern is used to instantiate new object by copying all of the properties
of an existing object, creating an independent clone.
Singleton pattern ensures single object of a particular class.
12. Can you describe all seven structural patterns in one line? (Interviewer
will not ask for all seven, only one or two)
Ans.
Adapter pattern is used to provide mechanism to link two incompatible types by
wrapping the “adaptee” with a class that supports the interface required by the
client.
Bridge pattern is used to separate the abstract element of a class from the
implementation details, providing the means to replace the implementation details
without modifying the abstraction.
Composite pattern is used to create hierarchical, recursive tree structures of
related objects where any element of the structure may be accessed and utilized in
a standard manner.
Decorator pattern is used to extend or alter the functionality of objects at run-time
by wrapping them in an object of a decorator class.
Façade pattern is used to define a simplified interface to a more complex
subsystem.
Flyweight pattern is used to reduce the memory and resource usage for complex
models containing many hundreds, thousands or hundreds of thousands of similar
objects.
Proxy pattern is used to provide a placeholder object, which references an
underlying object.
13. Can you describe all eleven behavioral patterns in one line? (Interviewer
will not ask for all eleven, only one or two)
Ans.
Chain of Responsibility pattern is used to process varied requests, each of which
may be dealt with by a different handler.
Command pattern is used to express a request, including the call to be made and
all of its required parameters, in a command object.
Interpreter pattern is used to define the grammar for instructions that form part of a
language or notation, whilst allowing the grammar to be easily extended.
Iterator pattern is used to provide a standard interface for traversing a collection of
items in an aggregate object without the need to understand its underlying structure.
Mediator pattern is used to reduce coupling between classes that communicate
with each other by sending messages via a mediator object.
Memento pattern is used to capture the current state of an object and store it in
such a manner that it can be restored at a later time without breaking the rules of
encapsulation.
Observer pattern is used to allow an object to publish changes to its state. Other
objects subscribe to be immediately notified of any changes.
State pattern is used to alter the behavior of an object at runtime as its internal state
changes.
Strategy pattern is used to create an interchangeable family of algorithms from
which the required process is chosen at run-time.
Template Method pattern is used to define the basic steps of an algorithm and
allow the implementation of the individual steps to be changed.
Visitor pattern is used to separate a relatively complex set of structured data
classes from the functionality that may be performed upon the data that they hold.

Más contenido relacionado

La actualidad más candente

Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
11prasoon
 

La actualidad más candente (20)

Let us understand design pattern
Let us understand design patternLet us understand design pattern
Let us understand design pattern
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Introduction to Design Pattern
Introduction to Design  PatternIntroduction to Design  Pattern
Introduction to Design Pattern
 
Singleton design pattern
Singleton design patternSingleton design pattern
Singleton design pattern
 
Overview of UML Diagrams
Overview of UML DiagramsOverview of UML Diagrams
Overview of UML Diagrams
 
Factory Method Pattern
Factory Method PatternFactory Method Pattern
Factory Method Pattern
 
SOLID Principles and The Clean Architecture
SOLID Principles and The Clean ArchitectureSOLID Principles and The Clean Architecture
SOLID Principles and The Clean Architecture
 
Grasp Patterns.ppt
Grasp Patterns.pptGrasp Patterns.ppt
Grasp Patterns.ppt
 
SOLID Principles
SOLID PrinciplesSOLID Principles
SOLID Principles
 
C# - Part 1
C# - Part 1C# - Part 1
C# - Part 1
 
Domain model
Domain modelDomain model
Domain model
 
Introduction to Design Patterns and Singleton
Introduction to Design Patterns and SingletonIntroduction to Design Patterns and Singleton
Introduction to Design Patterns and Singleton
 
Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans Spring - Part 1 - IoC, Di and Beans
Spring - Part 1 - IoC, Di and Beans
 
Spring User Guide
Spring User GuideSpring User Guide
Spring User Guide
 
Design Patterns
Design PatternsDesign Patterns
Design Patterns
 
Design pattern-presentation
Design pattern-presentationDesign pattern-presentation
Design pattern-presentation
 
Design Patterns - General Introduction
Design Patterns - General IntroductionDesign Patterns - General Introduction
Design Patterns - General Introduction
 
Hibernate tutorial
Hibernate tutorialHibernate tutorial
Hibernate tutorial
 
Coupling , Cohesion and there Types
Coupling , Cohesion and there TypesCoupling , Cohesion and there Types
Coupling , Cohesion and there Types
 
Oop java
Oop javaOop java
Oop java
 

Destacado

Top 9 design pattern interview questions answers
Top 9 design pattern interview questions answersTop 9 design pattern interview questions answers
Top 9 design pattern interview questions answers
hudsons168
 
Sensory Needs, Autism and Expectations
Sensory Needs, Autism and ExpectationsSensory Needs, Autism and Expectations
Sensory Needs, Autism and Expectations
Colleen Nagle Tryner
 
Carlos Ruiz Zafón
Carlos Ruiz Zafón Carlos Ruiz Zafón
Carlos Ruiz Zafón
ESO1
 
Presentación 5
Presentación 5Presentación 5
Presentación 5
ESO1
 
COSPE 2012 - Gender equality palestine_EN
COSPE 2012 - Gender equality palestine_ENCOSPE 2012 - Gender equality palestine_EN
COSPE 2012 - Gender equality palestine_EN
Massimo Alone
 
Soa design pattern
Soa design patternSoa design pattern
Soa design pattern
Lap Doan
 
Java Design Pattern Interview Questions
Java Design Pattern Interview QuestionsJava Design Pattern Interview Questions
Java Design Pattern Interview Questions
jbashask
 

Destacado (20)

29 Essential AngularJS Interview Questions
29 Essential AngularJS Interview Questions29 Essential AngularJS Interview Questions
29 Essential AngularJS Interview Questions
 
Job evaluation process - compensation management - Manu Melwin Joy
Job evaluation process -  compensation management - Manu Melwin JoyJob evaluation process -  compensation management - Manu Melwin Joy
Job evaluation process - compensation management - Manu Melwin Joy
 
Top 9 design pattern interview questions answers
Top 9 design pattern interview questions answersTop 9 design pattern interview questions answers
Top 9 design pattern interview questions answers
 
Let's investigate
Let's investigateLet's investigate
Let's investigate
 
A Biblioteca FEA em números - 2015
A Biblioteca FEA em números - 2015A Biblioteca FEA em números - 2015
A Biblioteca FEA em números - 2015
 
まわりをまきこむ
まわりをまきこむまわりをまきこむ
まわりをまきこむ
 
Sensory Needs, Autism and Expectations
Sensory Needs, Autism and ExpectationsSensory Needs, Autism and Expectations
Sensory Needs, Autism and Expectations
 
The Indian Entrepreneur
The Indian Entrepreneur The Indian Entrepreneur
The Indian Entrepreneur
 
Carlos Ruiz Zafón
Carlos Ruiz Zafón Carlos Ruiz Zafón
Carlos Ruiz Zafón
 
Presentación 5
Presentación 5Presentación 5
Presentación 5
 
COSPE 2012 - Gender equality palestine_EN
COSPE 2012 - Gender equality palestine_ENCOSPE 2012 - Gender equality palestine_EN
COSPE 2012 - Gender equality palestine_EN
 
f/21 Quarterly Q4|2015
f/21 Quarterly Q4|2015f/21 Quarterly Q4|2015
f/21 Quarterly Q4|2015
 
Cyberbullying
CyberbullyingCyberbullying
Cyberbullying
 
TolunaTopics: Entrepreneurship in France and US
TolunaTopics: Entrepreneurship in France and USTolunaTopics: Entrepreneurship in France and US
TolunaTopics: Entrepreneurship in France and US
 
Soa design pattern
Soa design patternSoa design pattern
Soa design pattern
 
リピートオーダーを増やすデジタルコミュニケーション戦略
リピートオーダーを増やすデジタルコミュニケーション戦略リピートオーダーを増やすデジタルコミュニケーション戦略
リピートオーダーを増やすデジタルコミュニケーション戦略
 
IAB Presentation
IAB PresentationIAB Presentation
IAB Presentation
 
Madonna
MadonnaMadonna
Madonna
 
UEDA Annual Summit 2016: The Center for Research in SEAD Education - "Moving ...
UEDA Annual Summit 2016: The Center for Research in SEAD Education - "Moving ...UEDA Annual Summit 2016: The Center for Research in SEAD Education - "Moving ...
UEDA Annual Summit 2016: The Center for Research in SEAD Education - "Moving ...
 
Java Design Pattern Interview Questions
Java Design Pattern Interview QuestionsJava Design Pattern Interview Questions
Java Design Pattern Interview Questions
 

Similar a Basic design pattern interview questions

UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)
Miriam Ruiz
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design Patterns
Jason Townsend, MBA
 

Similar a Basic design pattern interview questions (20)

Design patterns
Design patternsDesign patterns
Design patterns
 
Software Design Patterns - An Overview
Software Design Patterns - An OverviewSoftware Design Patterns - An Overview
Software Design Patterns - An Overview
 
Design pattern 1
Design pattern 1Design pattern 1
Design pattern 1
 
Software design and Architecture.pptx
Software design and Architecture.pptxSoftware design and Architecture.pptx
Software design and Architecture.pptx
 
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
dotnet stuff.com tutorials-design-patterns_exploring-net-design-patterns-in-s...
 
Top 30 Technical interview questions
Top 30 Technical interview questionsTop 30 Technical interview questions
Top 30 Technical interview questions
 
OOP design patterns
OOP design patternsOOP design patterns
OOP design patterns
 
Unit No 6 Design Patterns.pptx
Unit No 6 Design Patterns.pptxUnit No 6 Design Patterns.pptx
Unit No 6 Design Patterns.pptx
 
Design Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur UniversityDesign Pattern Notes: Nagpur University
Design Pattern Notes: Nagpur University
 
UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)UML Design Class Diagrams (2014)
UML Design Class Diagrams (2014)
 
Bartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design PatternsBartlesville Dot Net User Group Design Patterns
Bartlesville Dot Net User Group Design Patterns
 
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
Typescript design patterns applied to sharepoint framework - Sharepoint Satur...
 
Software Design Patterns
Software Design PatternsSoftware Design Patterns
Software Design Patterns
 
Object-Oriented Analysis and Design
Object-Oriented Analysis and DesignObject-Oriented Analysis and Design
Object-Oriented Analysis and Design
 
ap assignmnet presentation.pptx
ap assignmnet presentation.pptxap assignmnet presentation.pptx
ap assignmnet presentation.pptx
 
Review oop and ood
Review oop and oodReview oop and ood
Review oop and ood
 
Oops design pattern_amitgupta
Oops design pattern_amitguptaOops design pattern_amitgupta
Oops design pattern_amitgupta
 
Behavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka PradhanBehavioral pattern By:-Priyanka Pradhan
Behavioral pattern By:-Priyanka Pradhan
 
Design Pattern in Software Engineering
Design Pattern in Software Engineering Design Pattern in Software Engineering
Design Pattern in Software Engineering
 
Ooad 2
Ooad 2Ooad 2
Ooad 2
 

Más de jinaldesailive

Más de jinaldesailive (6)

Wcf tutorials
Wcf tutorialsWcf tutorials
Wcf tutorials
 
State Management In ASP.NET And ASP.NET MVC
State Management In ASP.NET And ASP.NET MVCState Management In ASP.NET And ASP.NET MVC
State Management In ASP.NET And ASP.NET MVC
 
Exam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NETExam 70 480 CSS3 at Jinal Desai .NET
Exam 70 480 CSS3 at Jinal Desai .NET
 
OOPS With CSharp - Jinal Desai .NET
OOPS With CSharp - Jinal Desai .NETOOPS With CSharp - Jinal Desai .NET
OOPS With CSharp - Jinal Desai .NET
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive   jinal desaiMvc interview questions – deep dive   jinal desai
Mvc interview questions – deep dive jinal desai
 
Software design principles - jinal desai
Software design principles - jinal desaiSoftware design principles - jinal desai
Software design principles - jinal desai
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 

Último (20)

A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?A Year of the Servo Reboot: Where Are We Now?
A Year of the Servo Reboot: Where Are We Now?
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
Apidays Singapore 2024 - Scalable LLM APIs for AI and Generative AI Applicati...
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot ModelNavi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Navi Mumbai Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
A Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source MilvusA Beginners Guide to Building a RAG App Using Open Source Milvus
A Beginners Guide to Building a RAG App Using Open Source Milvus
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 

Basic design pattern interview questions

  • 1. Articles from Jinal Desai .NET Basic Design Patterns Interview Questions 2013-06-01 05:06:51 Jinal Desai 1. What is Design Patterns? Ans. Design patterns are time tested reusable design solutions to recurring problems in application development. 2. What is Gang of Four in design patterns? Ans. The Gang of Four are the four authors of the book, “Design Patterns: Elements of Reusable Object-Oriented Software”. The four authors were Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides. The Gand of Four(GoF) terminology refers to the book or either author in design pattern. GoF patterns are generally considered foundation for all other patterns. 3. How many total patterns are there in GoF? Ans. There are total 23 patterns in GoF. 4. What are the categories design patterns divided into? Ans. There are total three categories into which design patterns divided. Creational Pattern:Creational patterns provide ways to instantiate single objects or group of related objects. Structural Patterns:Structural patterns provide a way to define relationship between classes and objects. Behavioral Patterns:Behavioral patterns define ways of communication between classes and objects. 5. Can you give name of patterns fall in each category? Ans. Five patterns fall under creational pattern. Abstract Factory Factory Factory Method Prototype Singleton Seven patterns fall under structural pattern. Adapter Bridge Composite Decorator Façade Flyweight Proxy Eleven patterns fall under behavioral pattern. Chain of Responsibility Command Interpreter
  • 2. Iterator Mediator Memento Observer State Strategy Template Method Visitor 6. What are object patterns? Ans. Object patterns deals with object relationships that can be changed at runtime. It specify the relationships between objects. The purpose of object pattern is to allow the instances of different classes to be used in the same place in a pattern. Object patterns avoid fixing the class that accomplishes a given task at compile time. Instead the actual class of the object can be chosen at runtime. Object patterns mostly use object composition to establish relationships between objects. 7. What are class patterns? Ans. Class patterns deals with class relationships that can be changed at compile time. It specify relationship between classes and their subclasses. Thus, class patterns tend to use inheritance to establish relationships. Unlike object patterns and object relationships, class patterns generally fix the relationship at compile time. They are less flexible and dynamic and less suited to polymorphic approaches. 8. What is class scope in class patterns? Ans. Class scope in class patterns is defined at design(compile) time. Class scope is built in the structure and relationship of classes. 9. What is object scope in object patterns? Ans. Object scope in object patterns is defined at runtime. Object scope is based on the relationship of objects(mostly object composition). 10. Can you list down different class patterns and object patterns? Ans. Class Patterns Adapter Factory Method Interpreter Template Method Object Patterns Abstract Factory Builder Bridge Chain of Responsibility Command Composition Decorator
  • 3. Façade Flyweight Iterator Mediator Memento Observer Prototype Proxy Singleton State Strategy Visitor Following is reference table for distribution of design patterns into Class or Object Patterns and categories of patterns(Creational, Structural and Behavioral). Purpose Creational Structural Behavioral Scope Class Factory Method Adapter Interpreter Template Method Object Abstract Factory Builder Prototype Singleton Bridge Composite Decorator Facade Flyweight Proxy Chain of Responsibility Command Iterator Mediator Memento Flyweight Observer State Strategy Visitor 11. Can you describe all five creational patterns in one line? (Interviewer will not ask for all five, only one or two) Ans. Abstract Factory pattern is used to provide a client with set of “family” of objects created by the factory which is determined at runtime. Builder pattern is used to create complex objects with internal parts that must be created in the same order or using a specific algorithm. Factory Method pattern is used to replace class constructors, abstracting the process of object generation in a way that the type of object instantiated can be determined at runtime. Prototype pattern is used to instantiate new object by copying all of the properties of an existing object, creating an independent clone. Singleton pattern ensures single object of a particular class. 12. Can you describe all seven structural patterns in one line? (Interviewer will not ask for all seven, only one or two)
  • 4. Ans. Adapter pattern is used to provide mechanism to link two incompatible types by wrapping the “adaptee” with a class that supports the interface required by the client. Bridge pattern is used to separate the abstract element of a class from the implementation details, providing the means to replace the implementation details without modifying the abstraction. Composite pattern is used to create hierarchical, recursive tree structures of related objects where any element of the structure may be accessed and utilized in a standard manner. Decorator pattern is used to extend or alter the functionality of objects at run-time by wrapping them in an object of a decorator class. Façade pattern is used to define a simplified interface to a more complex subsystem. Flyweight pattern is used to reduce the memory and resource usage for complex models containing many hundreds, thousands or hundreds of thousands of similar objects. Proxy pattern is used to provide a placeholder object, which references an underlying object. 13. Can you describe all eleven behavioral patterns in one line? (Interviewer will not ask for all eleven, only one or two) Ans. Chain of Responsibility pattern is used to process varied requests, each of which may be dealt with by a different handler. Command pattern is used to express a request, including the call to be made and all of its required parameters, in a command object. Interpreter pattern is used to define the grammar for instructions that form part of a language or notation, whilst allowing the grammar to be easily extended. Iterator pattern is used to provide a standard interface for traversing a collection of items in an aggregate object without the need to understand its underlying structure. Mediator pattern is used to reduce coupling between classes that communicate with each other by sending messages via a mediator object. Memento pattern is used to capture the current state of an object and store it in such a manner that it can be restored at a later time without breaking the rules of encapsulation. Observer pattern is used to allow an object to publish changes to its state. Other objects subscribe to be immediately notified of any changes. State pattern is used to alter the behavior of an object at runtime as its internal state changes. Strategy pattern is used to create an interchangeable family of algorithms from which the required process is chosen at run-time. Template Method pattern is used to define the basic steps of an algorithm and allow the implementation of the individual steps to be changed. Visitor pattern is used to separate a relatively complex set of structured data classes from the functionality that may be performed upon the data that they hold.