Software Construction: Design Patterns 1

Cards to learn the design patterns

Cards to learn the design patterns


Set of flashcards Details

Flashcards 14
Language Deutsch
Category Computer Science
Level University
Created / Updated 28.12.2019 / 10.11.2024
Weblink
https://card2brain.ch/box/20191228_software_construction_design_patterns_1
Embed
<iframe src="https://card2brain.ch/box/20191228_software_construction_design_patterns_1/embed" width="780" height="150" scrolling="no" frameborder="0"></iframe>

The Singleton Pattern (Definition)

The Singleton Pattern ensures a class has only one instance, and provides a global point of access to it.

Class Diagram of Singleton Pattern

Singleton Pattern Implementation Example (Eagerly created instance)

Eagerly created instance

The Adapter Pattern (Definition)

The Adapter Pattern converts the interface of a class into another interface the clients expect. Adapter lets classes work together that could not otherwise because of incompatible interfaces.

Class Diagram of Adapter Pattern

Adapter Pattern Implementation Example (Ducks & Turkeys)

The Observer Pattern (Definition)

The Observer Pattern defines a one-to-many dependency between objects so that when one object changes state, all of its dependents are notified and updated automatically.

Design Principle (Observer Pattern?)

Strive for loosely coupled designs between objects that interact.

Class Diagram of Weather Station (Observer Pattern)

The Iterator Pattern (Definition)

The Iterator Pattern provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Class Diagram of Iterator Pattern

Aggregate ist z.B. ein Menu Interface während ConcreteAggregate eine spezifische Implementation dessen ist. Die spezifische Implementation benötigt weiter eine spezifische Implementation des Iterator Interfaces bzw. einen ConcreteIterator. Der Client, z.B. der Kellner im Beispiel, muss nur die beiden Interfaces nutzen (!=implementieren!).

Example Class Diagram of Iterator Pattern in Restaurant

The Iterator Design Pattern (Definition)

An Iterator provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Class Diagram of Iterator Pattern