die Datenkapselung (pl. -en) – (data) encapsulation
Encapsulation is one of the main principles of OOP (yes, I’m still following this theme, and the next few posts will also be on terms related to it).
The other two main principles that are usually mentioned alongside encapsulation are polymorphism (which was covered last week) and inheritance (which will be covered next week).
Encapsulation is information hiding. That’s because we don’t want to expose unnecessary information, and generally, we only want the object to be able to manipulate its own data directly.
Some classes will have methods that are called mutators, which allow other classes to change its state. They may also have accessors, that allow other classes to read their private variables.
They are called getters (Abfragemethoden) and setters (Änderungsmethoden). In German, the term used for either one of them is eine Zugriffsfunktion or eine Zugriffsmethode. This term is applied to both getters and setters.
At this point, I shall digress a little to talk about the relationship between objects and classes.
I realised in the last post I did not really differentiate between a class and its object. Usually, the analogy that is used is the blueprint of a house and the house itself. The class is the blueprint, and the house is the object. You can have many objects of the same class, just as you could build multiple houses from the same blueprint.
Encapsulation is essential because, by keeping related things where they are, and not allowing unauthorised accesses, it also reduces the complexity of a system.
Etymology
The word Kapsel from which we get Kapselung is from Late Middle High German kapsel (according to Duden Online), also from capsella, borrowed from Middle Latin in the 15th century (according to Wiktionary, which claims Duden’s Das Herkunftswörterbuch as a source).
I’m not too sure of the order. The origin, in either case, comes from the Latin capsula.
This is apparently a diminutive form of capsa (German: Kassa/Kasse).
The meaning is a kind of a box or container, although Kasse, as I am familiar with it, has to do with a checkout or a cashier, the thing that holds money.
(Interestingly, the Wiktionary page for Behältnis – container – shows a piggy bank.)
A capsule still holds the sense of a form of container, like a medicine capsule or a time capsule.
Leave a Reply