0
Give me a real time examples for encapsulation
2 Respuestas
+ 9
Real data project,a big project, should be based on encapsulation approach. What that means? You should have no direct access to the inherited fields, to change the value of those and so on. You should use just get methods of the already written code, or just use the written methods without having an access to change the functionality of them.
That is just a simple example how the encapsulation should work in a real project. From my personal opinion, every single used API should be encapsulated.
+ 7
For example, if you develop a banking software, which deals with bank accounts, you would declare the balance variable as private, and make it accessible only to those methods, which are allowed to access and change the balance.
So, by utilizing the concept of Encapsulation, some level of security is achieved.