comp.lang.ada
 help / color / mirror / Atom feed
From: Jim Rogers <jrogers@omnitech.com>
Subject: Re: Ada features
Date: 2000/01/28
Date: 2000-01-28T00:00:00+00:00	[thread overview]
Message-ID: <86t5pq$tb7$1@nnrp1.deja.com> (raw)
In-Reply-To: 86sinj$upb$1@netserv.univ-lille1.fr

In article <86sinj$upb$1@netserv.univ-lille1.fr>,
  "Bertrand Augereau" <Augereau.Bertrand@ec-lille.fr> wrote:
> Hello,
>
> I would like to know if there are standard solutions for those 2
things in
> Ada95 :
>
> 1) Introspection

Not a term used in Ada 95.
In standard English this implies some sort of self review or
knowledge. What is your meaning here?

>
> 2) The equivalence of what is done in Java by :
> class MVFramework
>
>         class Model extends Object {...}
>         class View extends Object {...}
> }
> class MVSpreadsheetFramework extends MVFramework
>
>         class Model {...} // Overrides class MVFramework.Model
>         class View {...}
> }
>
> .i.e. overriding a nested class

Ada 95 implements inheritance through type extension.
A component of a tagged type may be another tagged type.
Each tagged type must be overridden separately.
To achieve the Ada equivalent of overriding a nested class,
you need to create a tagged type with elements which are
access to class-wide types.

There is also no direct Ada equivalent of the Java class Object.


type Model is tagged private;
...
type Model_Access is access all Model'Class;

type View is tagged private;
...
type View_Access is access all View'Class;

type FrameWork is tagged record
   This_Model : Model_Access;
   This_View  : View_Access;
end record;

Types View and Model can be extended indefinitely.
Those extensions can still used in type FrameWork.

This approach is not without problems.
Children of View and Model will possibly
have additional subprograms not in View or Model.
There is no simple way to access those subprograms without
explicitly coding a decision tree based upon the specific
tag of each descendant.

It is much easier to override behavior only, and not
both behavior and state.

In Ada behavior is overridden and data (state) is extended
through inheritance. Violating that rule makes life
difficult. It is often easier to take another look at the
problem and redesign the solution to fit the tools, instead
of fighting the tools.  This advice is good for all languages.

--
Jim Rogers
Colorado Springs, Colorado USA


Sent via Deja.com http://www.deja.com/
Before you buy.




  parent reply	other threads:[~2000-01-28  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-01-28  0:00 Ada features Bertrand Augereau
2000-01-28  0:00 ` Tucker Taft
2000-01-28  0:00 ` Jim Rogers [this message]
2000-01-29  0:00   ` Bertrand Augereau
replies disabled

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