Design Patterns Flashcards

1
Q

Advantages of Object Oriented Programming

A

Each Object easier to implement, maintain and reuse
- divide and conquer
Flexible combinations possible
- Versatility

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

Disadvantages of Object Oriented Programming

A

Behavior distributed across multiple objects
- lack of clarity (Unübersichtlichkeit)
Any change of one object my affect many others
- interdependence

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

Design Patterns - Observer Pattern
Communication without coupling

How and Why?

A

Decouple data model from parties/ observers that are interested in changes of its internal state

  • Subject shouldnt know details of observers
  • identity and number of observers may vary
  • polling is inappropriate and inefficient (nachfrage obs ein update im subject gibt)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Advantages of the Observer Pattern

A
  • abstract coupling between subject and observer

- support for broadcast communication

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

Disadvantages of the Observer Pattern

A
  • update cascades
  • update for all observers even though they may not be interested
  • missing details about change
  • limited communication interface -> subject cannot send optional parameters
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Observer Pattern - Implementation

who should inform observer of state change?

A

Method that changes the state notifies the observers
-> direct notification after change of state

Client triggerst update
-> if several changes performed at once only one notification needed

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

Design Patterns - Factory Method

Participants

A

Product
- interface of objects created by factoryMethod()
ConcreteProduct
- implements product interface
Creator
- declares factory method that returns object of product
ConcreteCreator
- overrides factoryMethod() to return instance of conreteProduct

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

Factory Methods - Consequences and Variants

A
  • client code only knows product interface -> works with any specific concreteproduct class
  • provides hook for subclasses

Variants

  • creator abstract
  • creator is concrete and provides default implementation
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Design Patterns - Abstract Factory

Motivation

A

For complete abstraction of the database
- clients only needs to interact with interface
avoid knowing the concrete type at creation time

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

Abstract Factory - Consequences

A

+ abstracts away from concrete products
+ changing product families is easy
+ ensures consistency among products

  • adding unforeseen kinds of products difficult
  • client needs to know hot to use factory (interface) instead of constructor
How well did you know this?
1
Not at all
2
3
4
5
Perfectly