This is the second of a 4 part series, for those of you new to object-oriented programming, discussing the 4 major principles of an object-oriented language: Data Abstraction, Encapsulation we’ve already discussed, Polymorphism and Inheritence. Data abstraction is the simplest of principles to understand. Data abstraction and encapuslation are closely tied together, because a simple definition of data abstraction is the development of classes, objects, types in terms of their interfaces and functionality, instead of their implementation details. Abstraction denotes a model, a view, or some other focused representation for an actual item. Its the development of a software object to represent an object we can find in the real world. Encapsulation hides the details of that implementation.
Abstraction is used to manage complexity. Software developers use abstraction to decompose complex systems into smaller components. As development progresss, programmers know the functionality they can expect from as yet undeveloped subsystems. Thus, programmers are not burdened by considering the waysin which the implementation of later subsystesm will affect the design of earlier development.
The best definition of abstraction I’ve ever read is: “An abstraction denotes the essential characteristics of an object that distinguish it from all other kinds of object and thus provide crisply defined conceptual boundaries, relative to the perspective of the viewer.” — G. Booch, Object-Oriented Design With Applications, Benjamin/Cummings, Menlo Park, California, 1991.
Lets look at this code for a person object. What are some things that a person can do? Those things must be represented here in our software model of a person. Things such as how tall the person is, and the age of the person; we need to be able to see those. We need the ability for the person to do things, such as run. We need to be able to ask the person if they can read.
Public Class PersonPrivate _height As Int16
Public Property Height() As Int16
Get
Return _height
End Get
Set(ByVal Value As Int16)
_height = Value
End Set
End PropertyPrivate _weight As Int16
Public Property Weight() As Int16
Get
Return _weight
End Get
Set(ByVal Value As Int16)
_weight = Value
End Set
End PropertyPrivate _age As Int16
Public Property Age() As Int16
Get
Return _age
End Get
Set(ByVal Value As Int16)
_age = Value
End Set
End PropertyPublic Sub Sit()
‘ Code that makes the person sit
End SubPublic Sub Run()
‘ Code that makes the person run
End SubPublic Sub Cry()
‘ Code that make the person cry
End SubPublic Function CanRead() As Boolean
‘ Code that determines if the person can read
‘ and returns a true or false
End FunctionEnd Class

You can’t really see what the code is that makes the person run. This is encapsulation that we discuseed last week.
So, in short, data abstraction is nothing more than the implementation of an object that contains the same essential properties and actions we can find in the original object we are representing.
Very good explanaion of data Abstraction and encapsulation.
Thanks Mr.Raymond,
This article gives a nice introduction about abstraction.I had some confusion on abstraction and encapsulation.You have given good explanation with simple example.
Really thanks a lot…
balaji