Design Patterns

This quiz covers the concept of design patterns, their origin, the four essential elements of a pattern description, the Observer pattern in detail, other common patterns (Façade, Iterator, Decorator), and the role of patterns in supporting concept-level reuse in object-oriented software design

download Export
search_insights Statistics
stylus_note White Board
Quran
calculate Calculator
dictionary Dictionary
fullscreen Full Screen

QUESTION OF
Views #: 17
Questions #: 11
Time: 9 minutes
Pass Score: 80.0%
Style
Mode

Origin of Design Patterns

1 pts
volume_mute

Design patterns were derived from ideas originally put forward by Christopher Alexander. What was the key insight from Alexander's work that was applied to software design?

note_alt Add notes
flag Flag

Correct Answer

Explanation

The Gang of Four

1 pts
volume_mute

The most influential set of design patterns was published in 1995. Which of the following correctly describes this publication and its significance?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Four Essential Elements of a Design Pattern

1 pts

The Gang of Four defined four essential elements that every design pattern description should include. Match each element to its correct description.

To complete the line match

  1. Click on an item in the first group
  2. Click on the match in the second group

To delete a match, double click on a line

Element

Name
Solution description
Problem description
Consequences

Description

A meaningful reference to the pattern - patterns become part of the vocabulary for discussing designs
Explains when the pattern may be applied, including motivation (why it is useful) and applicability (situations where it may be used)
A template for the design solution that can be instantiated in different ways; describes the parts, their relationships and responsibilities; often expressed graphically showing object relationships
A statement of the results and trade-offs of applying the pattern; helps designers understand whether the pattern can be used in a particular situation
note_alt Add notes
flag Flag

Correct Answer

Explanation

Observer Pattern - Description

1 pts
volume_mute

The Observer pattern is one of the most widely used design patterns. Which of the following correctly describes what problem it solves and how?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Observer Pattern - Four Objects

1 pts

The Observer pattern involves two abstract objects and two concrete objects. Match each object to its role.

Subject Attach (Observer) Detach (Observer) Notify () Observer Update () ConcreteSubject GetState () subjectState ConcreteObserver Update () observerState for all o in observers o -> Update () return subjectState observerState = subject -> GetState ()

To complete the line match

  1. Click on an item in the first group
  2. Click on the match in the second group

To delete a match, double click on a line

Object

Observer
Subject
ConcreteObserver
ConcreteSubject

Role

Abstract object that maintains state and provides Attach, Detach, and Notify operations; does not know details of the concrete class
Abstract object that defines the Update() interface that all observers must implement
Inherits from Subject; maintains subjectState and provides GetState(); notifies observers when state changes
Inherits from Observer; maintains a copy of subjectState and implements Update() to keep its copy in step with the subject
note_alt Add notes
flag Flag

Correct Answer

Explanation

Observer Pattern - Consequences

1 pts
volume_mute

Which of the following correctly describes a consequence (trade-off) of using the Observer pattern?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Four Common Design Pattern Problems

1 pts

The Gang of Four documented problems that commonly arise in OO design. Match each problem to the pattern that solves it.

To complete the line match

  1. Click on an item in the first group
  2. Click on the match in the second group

To delete a match, double click on a line

Problem

Tell several objects that the state of some other object has changed
Tidy up the interfaces to a number of related objects that have often been developed incrementally
Provide a standard way of accessing the elements in a collection, irrespective of how that collection is implemented
Allow for the possibility of extending the functionality of an existing class at runtime

Pattern

Decorator
Façade
Observer
Iterator
note_alt Add notes
flag Flag

Correct Answer

Explanation

Patterns vs Component Reuse

1 pts
volume_mute

Design patterns support 'concept-level reuse' rather than 'component reuse'. What is the key advantage of concept-level reuse through patterns compared to reusing executable components?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Using Patterns in Practice

1 pts
volume_mute

Which of the following statements about using design patterns in practice are TRUE? Select ALL that apply.

note_alt Add notes
flag Flag

Correct Answer

Explanation

Identifying the Right Pattern

1 pts
volume_mute

A data visualization dashboard displays the same dataset as both a pie chart and a bar chart. When the underlying data changes, both charts must automatically refresh. Which design pattern is most appropriate?

note_alt Add notes
flag Flag

Correct Answer

Explanation

Design Patterns - Key Points Summary

1 pts
volume_mute

Which of the following are TRUE about design patterns? Select ALL that apply.

note_alt Add notes
flag Flag

Correct Answer

Explanation