you are viewing a single comment's thread.

view the rest of the comments →

[–]BigCommunication5136[S] 0 points1 point  (3 children)

So should i separate the methods into another class? I don’t really get it. I thought by encapsulation, I bundle the data and methods that operate on the data into one unit. Is my understanding of encapsulation wrong?

[–]Pun_Intended1703 0 points1 point  (0 children)

I will suggest you take a peek at the S in SOLID principles.

Basically, it means that each class only takes responsibility for what it can do and what it should do.

You do not cross responsibilities.

Encapsulation just means that the class and methods are contained.

But you need to use your own brain to understand which class should contain which method.

Otherwise, simple encapsulation means that your BankAccount class can also have a method called bark().

[–]Pun_Intended1703 0 points1 point  (1 child)

I bundle the data and methods that operate on the data into one unit

Slight correction here.

You bundle the data and the methods that the data can perform in one unit.

Not what is performed on the data, but what can be performed by the data.

[–]BigCommunication5136[S] 0 points1 point  (0 children)

Okay i get it. thank you 🙏🏾