- The Program is divided into number of small units called Object. The data and function are build around these objects.
- The data of the objects can be accessed only by the functions associated with that object.
- The functions of one object can access the functions of other object.
The main idea behind Object Oriented Programming is simplicity, code reusability, extendibility, and security. These are achieved through Encapsulation, abstraction, inheritance, and polymorphism.
Abstraction( display only relevant info) has to do with displaying only the relevant aspect to the user, for example, turning on the radio, but you don't need to know how the radio works. Abstraction ensures simplicity.
Abstraction is achieved in either Abstract classes or interface in Java and Python.
Polymorphism (many forms) allows program code to have different meaning or functions.
Encapsulation (Data-Hidden) is the process of keeping classes private so they cannot be modified by external codes. . For example, if a developer wants to use a dynamic link library to display date and time, he does not have to worry about the codes in the date and time class rather he would simply use the data and time class by using public variables to call it up.
With this approach, a class can be updated or maintained without worrying about the methods using them. If you are calling up a class in ten methods and you need to make changes, you don’t have to update the entire methods rather you update a single class. Once the class is changed, it automatically updates the methods accordingly. Encapsulation also ensures that your data is hidden from external modification.
https://dotnettutorials.net/lesson/encapsulation-csharp/
No comments:
Post a Comment