Design Patterns Flashcards

1
Q

What are Software Patterns?

A

Standard solution to a recurring problem.

These solutions are successful and patch common problems.

This discipline emerged from the Object oriented community

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

What are the essentials of a software pattern?

A
  • Pattern Name: A handle used to describe the problem.
  • Problem: Explains context and how to apply pattern
  • Solution: Described elements, relationships, responsibilities and collaborators.
  • Consequences: result and tradeoffs, impact on flexibility, extensibility or portability
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are the classifications of Software patterns

A
  • Design patter: described by means of design constructs. Objects, classes, inheritance, aggregation, uses relationships.
  • Architectural Patterns: structural organization or schema for software systems. Set of predefined subsystems, responsibilities and inter-relationships
  • Idioms: Pattern whose form described by means of programming language constructs.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Explain the Factory design pattern

intent, structure, interface

A

Useful when base class of object is known but the subclass it belongs to is only known at run time when user provides input.

Structure: a superclass specifies all standard and generic behaviour. Delegates creation details to subclasses.

Interface: Client code needs an object of particular class. Calls a method known as factory class that instantiates the object.

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

Explain the Abstract Factory design pattern

intent, structure, interface

A

Provide interface for creating families of related or dependent objects without specifying concrete classes.

Structure: Uses a class to collect coordinated factory methods in one place, one class per style. Base class is named abstract factory, each subclass interprets its factory methods to produce objects of a single style.

Interface: client only interacts with abstract classes and never create objects directly.

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

Explain the Observer pattern

A

Underlying data is known as the observable and the views are known as the observers.

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

Define Software Architecture

A

High level design enabling engineers to understand overall structure of a project.

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

Define Architectural Patterns

A

Description of a set of predefined subsystems and their responsibilities.

Rules and guidelines for organizing the relationship among subsystems

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

Explain the Layered Architectural pattern

A

Structure applications that can be decomposed to subtasks. Each task an abstraction, each layer a service to the next layer. Each higher service uses a layer directly below.

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

Benefits of Layered Architectural pattern

A
  • lower level services can be used by many higher level services.
  • Inter layer changes do not affect other layers and each layer can be replaced by a different implementation.
  • Clearly defined levels of abstraction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Explain the Client-Server Architectural Pattern

A

Server component provides services to many clients.

Client requests services from server.

Server always listening for requests from client.

Ex: remote DB access, web based apps.

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

What are some limitations of Client-Server Pattern

A
  • Communication overhead

- Could require data transformation between data layer and server.

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

What are the different sessions of a Client-Server setup?

A

Stateless Server: Session state managed by client.

Stateful Server: Session state maintained by the server, associated with a client id.

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

Explain the Master-Slave Architectural Pattern

A
  • Supports parallel computation and fault tolerance.
  • Work distributed among identical components.
  • Master computes the final result from the returned work.

Ex: Process control, Embedded systems

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

Explain the Broker Architectural Pattern

A
  • Servers provide services.
  • Servers publish capabilities to a broker.
  • Clients request a service from a broker who picks a server from their published capabilities
  • Broker redirects client.
  • An Interface Definition Language (IDL) specifies the interface between the client and server. Then a Remote Procedure Call (RPC) mechanism, creates the code stubs to call functions across a network.

Think about CORBA and other web services.

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

Benefits of using Broker Pattern

A
  • Location transparency
  • Portability of system
  • Reusability of services. (Can remove and put services elsewhere)
  • Changeability and extensibility of components (Subscribe/notify new servers) IMPORTANT
17
Q

Explain the Peer-to-Peer Architectural Pattern

A
  • A symmetric client-server pattern
  • Peer acts as a client requesting services from another peer acting as a server.
  • Typically multithreaded.
18
Q

Explain the Model-View-Controller Architectural Pattern

A
  • For interactive applications divided into a model, view and controller component.
  • User input can change model, shown in view.
  • Think about iOS apps and other simple mobile applications.
19
Q

Limitations of using patterns

A
  • Patterns do not lead to direct code reuse.
  • Individual patterns are too simple (May use multiple)
  • Patterns are valiated by experiences , not testing.
  • Teams may suffer from too many patterns.