From: smize@Starbase.NeoSoft.COM (Samuel Mize)
Subject: Re: HELP-Information hiding/Abstraction (explain difference please)
Date: 12 Mar 1995 00:50:10 -0600
Date: 1995-03-12T00:50:10-06:00 [thread overview]
Message-ID: <3ju5j2$73q@Starbase.NeoSoft.COM> (raw)
In-Reply-To: j_green-070395115500@merlin.clh.icnet.uk
In article <j_green-070395115500@merlin.clh.icnet.uk>,
Jacky <j_green@icrf.icnet.uk> wrote:
>Could someone please explain the difference between
>information hiding and data abstraction - Is there one?
>
>I would be grateful for any simple small pieces of code that
>help show the difference.
-----------------------------------------------------------
Data abstraction:
package Abstractions is
type Stoplight_Color is (Red, Yellow, Green);
type Person is
record
Age: integer;
-- Lots more fields full of data -- but you can handle
-- a person as a single, higher-level item.
--
-- The concept "person" is abstracted.
--
-- The information is NOT hidden -- a
end record;
end Abstractions;
-----------------------------------------------------------
Information hiding:
package Hidden_Info is
type Person is private;
-- specs for procedures and functions on Person given here
private
type Person is
record
Age: integer;
-- Lots more fields full of data -- but you can handle
-- a person as a single, higher-level item.
--
-- The concept "person" is abstracted.
--
-- The information is HIDDEN -- someone using this package
-- CANNOT access the record fields. The user MUST user
-- the provided procedures and functions.
end record;
end Abstractions;
-----------------------------------------------------------
As a rule of thumb, information hiding is used to enforce
data abstractions.
Any time you create a user-defined type, you are defining a
data abstraction.
Any time you avoid putting implementation details into the
visible specification of a package, you are using information
hiding.
Samuel Mize - smize@starbase.neosoft.com
prev parent reply other threads:[~1995-03-12 6:50 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
1995-03-07 11:53 HELP-Information hiding/Abstraction (explain difference please) Jacky
1995-03-08 11:38 ` Tucker Taft
1995-03-12 6:50 ` Samuel Mize [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox