Lecture 6: Design Patterns Flashcards

1
Q

What is a design pattern?

A

Design pattern is a repeatable solution to a commonly occurring problem in software design which can be used in many different situations.

“Abstracts a recurring solution from a common problem in software design”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What does it improve?

A

documentation and maintenance

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

When solving the designs, what does it do?

A
  • More flexible
  • Elegant
  • Reusable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does a design class contain?

A
  • Dependencies
  • Structures
  • Interactions
  • Conventions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are the four elements that must be condsidered?

A
  1. Name
  2. Problem
  3. Solution
  4. Consequences and trade-offs application
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

4 Goals

A
  1. Arrange good design
  2. Good design structures and explicit names
  3. Capture and preserve design information
  4. Facilitate restructuring/refactoring
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the benefits of patterns?

A
  • Design reuse
  • Uniform design vocabulary
  • Enhance understanding, restructuring and team communication
  • Basics of automation
  • Abstracts from unimportant details
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is design pattern classification?

A

Design patterns level in their quantity and level of **abstraction **

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the purpose?

A

**Creational: **Process of object creation
Hides how instances are created
Separates the system from object creation

Structural: The composition of classes or objects

Behavioural: Characterise the ways in which classes or objects interact and distribute responsibilities

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Complete the Creational, Structural and Behavioural table

A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a behavioural relationship?

A
  • The design pattern is about the class’s objects communication
  • Most concerned with communication between objects
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an observer?

A

Defines one-to-many dependency between objects so that when one object changes state, all dependants are notified and updated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is strategy?

A

Defines a family of algorithms, Encapsulates an algorithm inside a class
- Encapsulate each one, and make them inchangeable to let clients and algorithms vary independently.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is chain of responsibility?

A

A way of passing a request between a chain of objects until a job is handled

Avoid coupling the sender of a request to its receiver by giving more than one object a chance to handle the request.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is Mediator?

A

Defines an object that encapsulates how a set of objects interact

  • Mediator promotes loose coupling by keeping objects from referring to each other explicitly by allow interaction independently
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is command?

A

Encapsulate a command request as an object

17
Q

What is Iterator?

A

Sequentially access the elements of a collection

18
Q

What is Visitor?

A

Defines new objects without a change of classes of the elements on which it operates

19
Q

What is structural relationships?

A

Structural uses using inheritance to compose interfaces. to obtain a new functionality

20
Q

What is Composite?

A

Compose object into a tree structure to represent whole-part.

Clients treat individual objects and compositions of object uniformly.

21
Q

What is decorator?

A

Transparently argument objects with new responsibilities dynamically

22
Q

What is Adapter?

A

Convert the interface of a class into another interface client expects; match interfaces with other classes known as Wrapper

23
Q

What is Bridge?

A

Decouple an abstraction (interface) from its (physical) implementation so the two can vary independently.

24
Q

What is Façade?

A

Façade is a single class that represents an entire subsystem that provides a unified interface to set of interfaces in a subsystem.

This defines a high-level interface that makes the subsystem easier to use.

25
Q

What is proxy and the special name?

A

An object representing another object known as Surrogate

  • Provide a surrogate or placeholder for another object to control access to it
  • Wrap a complicated subsystem with a simpler interface
26
Q

What is an abstarct factory?

A

Create families of related objects without specifying subclass names

27
Q

Which relationship is identical?

A

COMPOSITION and DECORATOR are identical