comp.lang.ada
 help / color / mirror / Atom feed
From: ruckert@mcs.mcs.newpaltz.edu (Martin Ruckert)
Subject: Question: Extensible subobject?
Date: 20 Jan 1995 22:02:00 GMT
Date: 1995-01-20T22:02:00+00:00	[thread overview]
Message-ID: <3fpbso$6g2@motss.newpaltz.edu> (raw)

I don't know enough about Ada to find the best solution to the following
problem using Ada. I would be interested in a solution to include it in a
comparison of major object oriented languages. So, someone out there
might know the answer.

Problem:
An interactive application presents texts to the user in windows.
Most of the texts are read only (help, messages, menus). The base class
is RO_Text, it has methods to provide read access to the text.

A subclass of RO_Text is Edit_Text, which defines some additional
data fields to do a more complex storage management and it provides
additional methods to allow changes to the text (e.g. insert a
character).

The base class for windows is RO_Window, it specifies a field t to be a
pointer to an RO_Text and has methods to perform all the updating of 
the screen to make the text visible.

I want the class Edit_Window to be a subclass of RO_Window. Edit_Window needs
additional methods to service requests to change the text shown (e.g.
inserting a character). This new methods will update the screen and it
should forward the message to its text.

I can create an Edit_Text and store the pointer to it in the field t of the
Edit_Window. So the text subobject has methods to perform the changes, but
the type of t is a pointer to a RO_Text. Will it allow access to the
necessary methods of the Edit_Text?

If I use a type conversion on t it needs runtime overhead for checking.
Type conversions should be avoided if anyway?

I would rather in Edit_Window redefine the type of t to be 
a pointer to Edit_Text. This enables the compiler to check that my
assignments to t are correct and spares the type conversion and the test
associated with it later.

Is it possible ?? How to handle it best ??

Martin

Address: ruckert@mcs.newpaltz.edu






             reply	other threads:[~1995-01-20 22:02 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1995-01-20 22:02 Martin Ruckert [this message]
1995-01-25 18:57 ` Question: Extensible subobject? Tucker Taft
replies disabled

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