Design Patterns Flashcards

1
Q

What kind of Design Patterns can generally be differentiated?

A
  • Constructural Patterns
  • Behavioral Patterns
  • Creational Patterns
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Name examples for Structural Patterns

A
  • Adapter
  • Proxy
  • Decorater
  • Bridge
  • Facade
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Name examples for Behavioral Patterns

A
  • State Pattern
  • Mediator
  • Observer
  • Strategy
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Name examples for Creational Patterns

A
  • Factory Pattern
  • Builder Pattern
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Describe the Adapter Pattern

A
  • when two not compatible interfaces need to be connected an Adapter can be used
  • wraps the one interface offering an compatible api to the other
  • transforms the input into a format compatible to the wrapped interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Describe the Observer Pattern

A
  • behavioral pattern
  • if one components should be aple to notify other components about changes without needing to know who these other components are
  • object should react to changes in subject without the subject knowing the observers
  • subject only knows, that they implement the observer interface
  • observer can register or unregister at any time
  • subjects contains a list of observers of type observer interface
  • subscribe method of subject takes interface type observer
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Describe the Decorater Pattern

A
  • adds dynamically and transparently new functionality to a component without expanding the component itself
  • base-component declares central interface for wrapper and wrappe, will be implemented by everyone
  • concrete base-component is the wrappe, wrapped by one or multiple potential decoraters
  • base decorater extend the base component and its method, and are implemented by concrete decoraters
  • wrapped component does not care about being wrapped and has no knowledge of it
  • decoraters have a field for the wrappee of the abstract type base-component
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Describe the Proxy Pattern

A
  • structural pattern
  • instead of communicating directly with a service, communication runs through a proxy that redirects requests to target service
  • both service and proxy implement the same interface
  • proxy has a field for the real service
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Describe the Facade Pattern

A
  • Structural pattern
  • a facade encapsulate logic and interfaces and makes specific information and functionality visible to the outside
  • presents a simpified interface to a complex subsystem
  • can also be used when a lot of technicall classes are used that are of no use for outside systems
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Describe the Bridge Pattern

A
  • structural pattern
  • seperates implementation from its interface allowing both to change independently
  • switches from inheritance to object composition
  • one dimension then contains the other dimension as an object
  • both abstraction and implementation are interfaces, where abstraction contains an implementation
  • both can be seperately implemented, decoupling them from each other
  • usually abstraction declares complex interface methods that then call multiple implementation functions
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Describe the State Pattern

A
  • Behavioral Pattern
  • instead of being only an attribute the state becomes its own object
  • these objects follow the same interface but have state-specific logic implemented in their overriding methods
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Describe the Mediator pattern

A
  • behavioral pattern
  • mediator controls how objects interact with each other
  • instead of speaking with each other the objects only communicate with the mediator
  • mediator decides what to do with communication and what other objects need to be contacted
  • concrete mediators often keep list of all relevant objcets to be connected
  • each component receives reference to mediator from abstract component interface
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Describe the Factory Pattern

A
  • creational pattern
  • instead of instancing new objects of certain types on their own components use an abstract factory of the abstract interface type of all these objects
  • factory itself can be implemented to cover expandable type of object list
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Describe the Combinator Pattern

A
  • allows to change multiple primitive operations of the same type together
  • allows to create clear and reusable code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly