Raymond Lewallen

Sponsors

The Lounge

Wicked Cool Jobs

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Data Abstraction Defined
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 Person

    Private _height As Int16
    Public Property Height() As Int16
        Get
            Return _height
        End Get
        Set(ByVal Value As Int16)
            _height = Value
        End Set
    End Property

    Private _weight As Int16
    Public Property Weight() As Int16
        Get
            Return _weight
        End Get
        Set(ByVal Value As Int16)
            _weight = Value
        End Set
    End Property

    Private _age As Int16
    Public Property Age() As Int16
        Get
            Return _age
        End Get
        Set(ByVal Value As Int16)
            _age = Value
        End Set
    End Property

    Public Sub Sit()
        ' Code that makes the person sit
    End Sub

    Public Sub Run()
        ' Code that makes the person run
    End Sub

    Public Sub Cry()
        ' Code that make the person cry
    End Sub

    Public Function CanRead() As Boolean
        ' Code that determines if the person can read 
' and returns a true or false End Function End Class
So, there we have started to create a software model of a person object; we have created an abstract type of what a person object is to us outside of the software world. The abstract person is defined by the operations that can be performed on it, and the information we can get from it and give to it. What does the abstracted person object look like to the software world that doesn't have access to its inner workings? It looks like this:

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.

Currently listening to: All Along the Watchtower - Dave Matthews Band with Phish

Posted Thu, Feb 17 2005 5:44 AM by Raymond Lewallen

[Advertisement]

Comments

TrackBack wrote Object Identity vs. Object Equality - Overriding System.Object.Equals(Object obj)
on Tue, Feb 22 2005 11:34 AM
TrackBack wrote Inheritance Defined
on Thu, Feb 24 2005 5:35 AM
TrackBack wrote Polymorphism Defined
on Tue, Mar 15 2005 6:03 AM
TrackBack wrote Polymorphism Defined (from: Raymond Lewallen)
on Wed, Mar 16 2005 8:14 PM
David Hayden wrote OOP and Design Pattern Resources
on Wed, Jan 18 2006 7:16 PM
 I received an email message via this blog for some help in identifying good recources on OOP and...
Balaji wrote re: Data Abstraction Defined
on Sat, Aug 12 2006 6:16 AM
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
Mesothelioma Law professional practising in Raymond, New Hampshire wrote Mesothelioma Law professional practising in Raymond, New Hampshire
on Tue, Dec 23 2008 4:27 PM

Pingback from  Mesothelioma Law professional practising in Raymond, New Hampshire

Find Hampshires in Hampshire wrote Find Hampshires in Hampshire
on Tue, Jul 21 2009 7:57 AM

Pingback from  Find Hampshires in Hampshire

new hampshire credit repair wrote new hampshire credit repair
on Fri, Dec 4 2009 9:51 PM

So many different ideas listed here - amazing..

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us