C
C
calculator2122021-12-14 09:30:13
OOP
calculator212, 2021-12-14 09:30:13

Why is the definition of encapsulation wrong?

The purpose of encapsulation is to group objects together, not to hide information, but many people still believe that encapsulation is about hiding, where did it even come from?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
D
Dmitry Belyaev, 2021-12-14
@calculator212

The purpose of encapsulation is the union of objects
who told you that?
The word encapsulation itself comes from the Latin "in capsula", which can be translated as "closed in a box".
The purpose of encapsulation is to hide complexity. Not information, not data, not code, but complexity.
Imagine you have a light bulb with a switch. You can simply press the switch to turn it on or off. You don't need to understand the electrical circuits inside this device to have light. You just need to use a simple interface - a switch. This is what encapsulation is. The interior of a light bulb with a switch is encapsulated from you.

A
Adamos, 2021-12-14
@Adamos

There is enough structure to combine objects, even OOP is not required.
In capsula - "in a box". Mandatory for normal architecture separation of internal data from external interfaces.
Of course, it also has nothing to do with "hiding information".
Read normal textbooks and do not listen to the nonsense that dropouts mumble into the cell.

K
Kirill Gorelov, 2021-12-14
@Kirill-Gorelov

Good question to ask you. Why did you give it wrong?)))
Well, come on answer;)

R
res2001, 2021-12-14
@res2001

Who knows, maybe from Wikipedia?
Access modifiers had to be included somewhere, so they stuffed them into encapsulation. Do not shove them into inheritance and polymorphism.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question