comp.lang.ada
 help / color / mirror / Atom feed
* Re: Example of object oriented Ada95 requested!
       [not found] <slrn4eumdg.4d.cabal@TerpTavern.umd.edu>
@ 1996-01-08  0:00 ` John Herro
  1996-01-08  0:00   ` Robert Dewar
  1996-01-08  0:00 ` Tucker Taft
  1 sibling, 1 reply; 3+ messages in thread
From: John Herro @ 1996-01-08  0:00 UTC (permalink / raw)


Arcadio A Sincero (cabal@TerpTavern.umd.edu) is using
Ada-Tutr and asking about examples of encapsulation,
inheritance, and polymorphism.

Dear Arcadio,
     You're absolutely right about the package being Ada's primary
mechanism for encapsulation.  As you get into the tutorial, you'll learn
how packages help contain the effects of changes to one part of the
program; this is even more true when you get into private types.
     The full advantages of inheritance and polymorphism (OOP) don't
really come into play until the project gets pretty large.  In my
tutorial, I try to keep the examples fairly simple.  While I expect the
user to grasp the examples, I only hint at the _advantages_ of OOP. 
Admittedly, I don't really expect the user to grasp the advantages until
he or she has worked with larger projects.
     Inheritance usually (but not always) refers to child packages and
heirarchical libraries.  Sometimes the word inheritance is also used with
derived types, which were available in Ada 83.  For example, if we write
type Count is new Integer; then type Count _inherits_ the operations that
Ada already knows for Integer, such as addition, subtraction, etc.  That
use of the word inheritance has little to do with OOP.  When used with
heirarchical libraries, inheritance refers to the fact that a child
package inherits resources from the parent, and can add additional
resources of its own.  The advantage is that the child package can be
modified and recompiled, without need to recompile the parent and the
program units that "with" only the parent.  On a large project, this can
save not only a lot of recompilation time, but a lot of time spent on
program redevelopment as the requirements are refined or changed.
     Polymorphism (meaning many forms) usually refers to tagged record
types.  The example in the tutorial of tagged type Date (having fields
Day, Month, and Year) and type Complete_Date (adding a day-of-week field
to type Date) is an example of polymorphism.  The advantages include the
fact that we can create heterogeneous linked lists, trees, and other
structures (containing Dates and Complete_Dates), and that we can have the
system decide at run time which of several subprograms to call, depending
on the type of an object, which might be pointed to by an access type. 
This feature is called dynamic dispatching.  Again the advantages show up
in larger projects.
     The code in your message is an excellent example of child packages,
which has to do with inheritance.  (Your code may have a few minor syntax
errors, such as "procedure HardDrive;" instead of "procedure HardDrive is"
in the package body.)  An example of polymorphism would involve _types_,
such as the tagged type Date in the tutorial.
     I hope this helps.  By the way, I'm presently working on a minor
update of Ada Tutor, which I expect to make available on the Web and by
FTP.  I'll announce it here as soon as it's released.
- John Herro
Software Innovations Technology




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Example of object oriented Ada95 requested!
  1996-01-08  0:00 ` Example of object oriented Ada95 requested! John Herro
@ 1996-01-08  0:00   ` Robert Dewar
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1996-01-08  0:00 UTC (permalink / raw)


John Herro says

"     Inheritance usually (but not always) refers to child packages and
heirarchical libraries.  Sometimes the word inheritance is also used with
derived types, which were available in Ada 83.  For example, if we write
type Count is new Integer; then type Count _inherits_ the operations that
Ada already knows for Integer, such as addition, subtraction, etc.  That
use of the word inheritance has little to do with OOP."

I find this *very* confusing, and bvery peculiar. I have never heard of
the word inheritance being used in connection with child packages, and
I don't think it is a useful application.

Inheritance in Ada is a technical term referring to inherited operations,
and yes, it is true that Ada 83 derived types provide inheritance, but
also it is an extension of this inheritance mechanism that is absolutely
fundamental to the OOP model in Ada 95.





^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Example of object oriented Ada95 requested!
       [not found] <slrn4eumdg.4d.cabal@TerpTavern.umd.edu>
  1996-01-08  0:00 ` Example of object oriented Ada95 requested! John Herro
@ 1996-01-08  0:00 ` Tucker Taft
  1 sibling, 0 replies; 3+ messages in thread
From: Tucker Taft @ 1996-01-08  0:00 UTC (permalink / raw)


Arcadio A. Sincero (cabal@TerpTavern.umd.edu) wrote:

: ...
:     Under the section entitled "Hierarchial Libraries", Dr.Herro talks about
: "child packages".  From what I can tell, this seems to be Ada95's idea of
: what inheritance and polymorphism.  Am I right?  ...

Nope.  "Tagged" types, with type extension and class-wide types, are what 
provide inheritance and polymorphism in Ada 95.

Child packages/hierarchical libraries are namespace/visibility
management mechanisms, somewhat analogous to C++ namespaces or
Modula-3 modules.

: ...
: Arcadio Alivio Sincero, Jr. 
: Sophomore, Computer Science Major at the University of Maryland 
: at College Park
: Email: lotu@wam.umd.edu, WWW: <still working on it!>

-Tucker Taft  stt@inmet.com
Intermetrics, Inc.




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-01-08  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <slrn4eumdg.4d.cabal@TerpTavern.umd.edu>
1996-01-08  0:00 ` Example of object oriented Ada95 requested! John Herro
1996-01-08  0:00   ` Robert Dewar
1996-01-08  0:00 ` Tucker Taft

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox