Kapselung (EN)
ConceptHiding internal implementation details and protecting data
Encapsulation in OOP
classDiagram class Fahrzeug { -geschwindigkeit: int -kraftstoff: float +beschleune(delta: int) +bremsen() +getGeschwindigkeit(): int +setGeschwindigkeit(value: int) } class PKW { -sitze: int +oeffneKofferraum() } class LKW { -ladung: float +ladeWare(gewicht: float) } Fahrzeug <|-- PKW Fahrzeug <|-- LKW In Context
- Typically used together with inheritance and polymorphism
- Related to: Abstraction, Data Encapsulation, Information Hiding
- Example use: Private fields with public getter/setter methods