Software Design Patterns
Test your knowledge of software design patterns including GoF patterns (Observer, Facade, Composite, Adapter, Singleton, Command, State) and GRASP patterns (Information Expert, Indirection, Polymorphism, Pure Fabrication), plus MVC architecture concepts.
Questions
How many GRASP patterns are there?
- 5
- 6
- 9
- 10
The Gang-of-Four (GoF) pattern is a set of
- 9
- 23
- 20
- 10
What are the categories of GoF patterns
- Conditional, Structural, Behavioral
- Ceational, Structural, Behavioral
- Factory, Command, Strategy
- Behavioral, Observer, Factory
The Singleton pattern:
- Defines multiple access points for a singleton
- supports multiple visibility forms for a singleton
- allows the creation of multiple class instances in the future without affecting the clients of the singleton class
- All of the above
Which GRASP patterns are supported by Adapter pattern
- Low coupling, High cohesion
- High Cohesion, Indirection
- Low Coupling, Polymorphism
- High Cohesion, Polymorphism
Key Concept for applying the Composite Pattern:
- Allows you to represent composite objects in the form of a hierarchy
- It uses independent interfaces for representing individual and composite objects
- It uses an individual object that is composed of two or more composite objects
- It represents just a collection of different objects
Key concept for using Facade pattern:
- Adapter pattern is used to access facades
- The Adapter pattern adds an indirection object for low coupling
- The Façade pattern hides the complexity of a subsystem from a client
- None of the above
The Pure Fabrication pattern
- Assigns responsibility to an intermediate object
- Creates a convenient class that supports high cohesion and low coupling
- Creates a convenient class that supports low cohesion and high coupling
- Protects the system from unexpected variations
GRASP Patterns generally provide
- Solutions to common problems
- Guiding Principles for designing a system
- General concepts of designing
- None of the above
The Polymorphism Pattern:
- Handles the message generated when a system event or operation takes place
- assigns the responsibility for creating new class instance or object
- Determine how a system handles conditional variations
- Creates a convenient class
The Indirection Pattern helps:
- Avoid direct coupling
- Maintain low coupling and high reusability
- None of the above
- Both A and B
The Information Expert Pattern:
- Is used in the process of alternative evaluation
- Determine how a system handles conditional variations
- Assign responsibilities to an intermediate object
- Defines guiding principles for assigning responsibilities to objects
Key Concept for applying the Command Pattern:
- It helps achieve proper fucntionality if the tasks are ordered
- it is mandatory that the sequence added to a transaction must be the best execution sequence possible
- The number of tasks to be executed affects the overall performance of a transaction
- None of the above
Key Concept for applying a State Pattern:
- Modifying a persistent object results in the instance update of the database
- Only one persistent object can refer to an instance of a class at any given time
- The transactional state of an object decides the response to an operation
- None of the above
It is easy to integrate a new client with the MVC Pattern because
- The model, view and the controller objects are independent of each other and can be easily used to integrate a new client's business logic
- The new client can be coded into the controller as additional business logic for the enterprise data
- The MVC pattern makes provisions for any new client at the time of development of the enterprise solution
- The MVC Pattern provides for many models to be used by one controller, thus making it easy to incorporate a new client
Identify a benefit of using the Model-View separation principle:
- Separation makes more space available for application and interface objects
- Separation ensures independence of business logic
- Separation is used for repeated testing of the code
- Separation makes it easier for the model and the view to define roles in times of performance
Identify a concept which is NOT related to MVC pattern among the below:
- The MVC pattern introduces extra classes due to the separation of the model,view and the controller components
- The view component accesses the enterprise data through the model component
- The model-view separation principle states that the application logic should not be put in the UI object method
- The Model-View separation principle helps minimize the impact of requirement change in the interface on the controller layer
Representing object as Tables Persistence pattern __________________________________
- Provides a uniform interface to the subsystem
- Defines a table for each persistent object class
- Assigns an object identifier for each record
- Makes a class resonsible for materialization
PersistenceFacade pattern _________________________
- Provides a uniform interface to the subsystem
- Assigns the responsibility for creating new class instance or object
- Makes a class responsible for materialization
- Makes the database mappers responsible for maintaining cache
The Observer pattern:
- Is a behavioral pattern that defines how a single class can be notified of a change
- Consider the objects displaying the data and the objects containing the data as a single entity.
- Is also known as the publish-subscribe model where an object can publish an event that has no subscribers
- None of the above