vault backup: 2025-01-17 11:54:18
This commit is contained in:
@@ -32,7 +32,7 @@ status: not_started
|
||||
|
||||
|
||||
---
|
||||
## Chapters
|
||||
## Introduction
|
||||
### Getting Started
|
||||
|
||||
> [!definition] UML Notation
|
||||
@@ -183,11 +183,55 @@ Goal: objects of class T may be replaced with objects of class S without alterin
|
||||
- No new exceptions should be introduced in subclass S
|
||||
--> A subclass S must require no more and promise no less than its superclass T
|
||||
|
||||
Example:
|
||||
Example: the contract requires must be the same or less strict (preconditions) and for the guarantees the subclass must guarantee the same or more than the superclass T (postconditions)
|
||||
|
||||
Be cautious about *accidental polymorphisms*: a completely different class that uses the same names. Usually the requires and guarantees are very different. This means syntax is the same, but semantics are different. Syntactically substitutionable but not semantically substitubable.
|
||||
|
||||
#### Design Principle: Favor Association over Inheritance
|
||||
Inheritance cannot change the behaviour at run-time: a rectangle shape cannot morph into a circle shape.
|
||||
|
||||
## Design Patterns
|
||||
Patterns are not mutually exclusive and can be used on top of each other.
|
||||
|
||||
|
||||
### Adapter Pattern
|
||||
- No prerequisits
|
||||
- Usually problems have same semantic, but a different syntax.
|
||||
- Reasons: too much client code to change, code not accessible, many clients that use the same code
|
||||
- Adapters are an intermediate code block that adapts the syntax between the two parts.
|
||||
- meaning you have one more layer, thus slightly less performance.
|
||||
- ![[Pasted image 20250117112716.png]]
|
||||
- use an adapter base class (PCLinuxGraphicsAdapter)
|
||||
- There is no guarantee that it is only the syntax that changes, maybe you need to adapt the semantics as well.
|
||||
### Façade
|
||||
|
||||
### Bridge
|
||||
|
||||
### Strategy
|
||||
|
||||
### Composite
|
||||
|
||||
### Observer
|
||||
|
||||
### Template Method
|
||||
|
||||
### Factory Method
|
||||
|
||||
### Abstract Factory
|
||||
|
||||
### Singleton
|
||||
|
||||
### Iterator
|
||||
|
||||
### Proxy
|
||||
|
||||
### Decorator
|
||||
|
||||
### Command
|
||||
|
||||
### State
|
||||
|
||||
### Data Access Object
|
||||
|
||||
---
|
||||
## Exercises
|
||||
|
||||
Reference in New Issue
Block a user