ENCAPSULATION is the grouping of data items and functions into a type. By this we mean, if you have operations you want to perform on a student, you would sum them up, both the properties of the student and the operations you want to perform on them and encapsulate them into a class.
So we would have the class student that can contain properties like
i. Name
ii. Age etc.
And also operations like
i. AssignStudentID
ii. ChangeDepartment etc.
This would make it more organized and resuable.
That's the advantage of encapsulation.
Showing posts with label Object Oriented Programming in C#. Show all posts
What is Abstraction?
Abstraction - It is the view of an object in context. For you to be performing an abstraction, you have to take a real world object and consider the properties of that object that are of use to your application.
EXAMPLE
If you have to make and abstraction while trying to write a software for calculating results at a university, properties of a person that would be of intrest to you would inculde:
i. Age
ii. Gender
iii. Program of study
You wouldn't be too interested in the persons relationship status.
This is because you are only concerned with things about the person that would enable you develop a working application. You are trying to view the person "in context".
EXAMPLE
If you have to make and abstraction while trying to write a software for calculating results at a university, properties of a person that would be of intrest to you would inculde:
i. Age
ii. Gender
iii. Program of study
You wouldn't be too interested in the persons relationship status.
This is because you are only concerned with things about the person that would enable you develop a working application. You are trying to view the person "in context".
Subscribe to:
Posts (Atom)
Follow Us
Were this world an endless plain, and by sailing eastward we could for ever reach new distances