comp.lang.ada
 help / color / mirror / Atom feed
From: Michael Paus <pausnospam@nospamib-paus.com>
Subject: Re: Idiom for a class and an object in Ada
Date: Wed, 20 Oct 2004 18:20:52 +0200
Date: 2004-10-20T18:20:52+02:00	[thread overview]
Message-ID: <cl6395$g1l$1@online.de> (raw)
In-Reply-To: <M3Ocd.237$5i5.72@newsread2.news.atl.earthlink.net>

Hi Marin,

your question has triggered an interesting discussion which I found
very amusing. Before I provide my proposal for a solution of your
problem I think it is essential to first discuss what the potential
benefits of your OO approach are.

You have chosen to use a tagged type to represent your A/D converters
which I think is a wise decision but neither you nor anybody else
seems to be able to give a good reason for that (if I have not missed it :-)
and also in the way you have started you are missing an opportunity
for flexibility in your design and for really exploiting your OO approach.

First of all your A/D converter class should be abstract and in all places
where you later access an A/D converter you should only refer to this abstract
base class. This gives you the possibility to easily exchange the implementation
of your A/D converter by providing different implementations of sub-classes of
your base class. The decision of which implementation you want to use can
even be done at run-time if you like. E.g., I often use this technique to
provide one sub-class for the real hardware and one which is only linked to
a simulation device which is connected via ethernet. I think this makes the
potential benefit of the OO approach clear.

Now that the goal is clearer it is easier to find a solution for your original
question. I like to be able to put together different configurations of my
software. E.g., one that is configured to run on the target and another one
which is used for a PC based simulation of the software and I want to change
as little of the software as necessary to create a new configuration.

I therefore have a
configuration specific main program and also a configuration specific package
which only has an "Initialize" and a "Start" procedure. As this package is
configuration specific no other package is allowed to access this package.
In this package I declare all the top level and configuration specific
objects statically and if some object needs another object I pass in a
class wide access value to the corresponding object in the "Initialize"
method. Alternatively you can also provide abstract factory packages for
these objects. This is useful in cases where an instance of these objects
is used in many places of your software.

 From a reusability point of view it is important that you keep the creation
of instances separate from the objects which use them. For me this approach
has worked very well and it even has some more advantages which I have not
discussed here.

Yours

Michael






  parent reply	other threads:[~2004-10-20 16:20 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-18 11:47 Idiom for a class and an object in Ada Marin David Condic
2004-10-18 12:14 ` Martin Krischik
2004-10-18 19:40   ` Matthew Heaney
2004-10-19 12:59   ` Marin David Condic
2004-10-19 14:46     ` Martin Dowie
2004-10-19 15:55       ` Matthew Heaney
2004-10-19 18:31         ` Martin Dowie
2004-10-19 15:52     ` Matthew Heaney
2004-10-18 12:26 ` Marius Amado Alves
2004-10-19  2:09   ` Jeffrey Carter
2004-10-19  3:28     ` Matthew Heaney
2004-10-19 12:53       ` Marin David Condic
2004-10-19 14:44         ` Matthew Heaney
2004-10-19 15:01           ` Dmitry A. Kazakov
2004-10-19 15:40             ` Matthew Heaney
2004-10-20  7:58               ` Dmitry A. Kazakov
2004-10-20 12:31                 ` Marin David Condic
2004-10-20 13:53                   ` Dmitry A. Kazakov
2004-10-20 15:23                   ` Matthew Heaney
2004-10-21 12:24                     ` Marin David Condic
2004-10-21 17:15                       ` Matthew Heaney
2004-10-20  5:39         ` Simon Wright
2004-10-20  7:24           ` Matthew Heaney
2004-10-20  8:39             ` Dmitry A. Kazakov
2004-10-21  1:36             ` Jeffrey Carter
2004-10-21  1:46               ` Matthew Heaney
2004-10-21  7:51                 ` Dmitry A. Kazakov
2004-10-21 12:45                   ` Matthew Heaney
2004-10-21 14:11                     ` Dmitry A. Kazakov
2004-10-22  1:04                 ` Jeffrey Carter
2004-10-22  1:36                   ` Matthew Heaney
2004-10-21 19:31               ` Kevin Cline
2004-10-21 22:02                 ` Matthew Heaney
2004-10-22  0:10                   ` Matthew Heaney
2004-10-21  8:25             ` Martin Dowie
2004-10-20 17:04           ` Matthew Heaney
2004-10-20 19:37             ` Simon Wright
2004-10-20 20:04               ` Matthew Heaney
2004-10-22  5:37                 ` Simon Wright
2004-10-20  1:10       ` Jeffrey Carter
2004-10-20  7:04         ` Matthew Heaney
2004-10-20 12:42           ` Marin David Condic
2004-10-20 12:55             ` Matthew Heaney
2004-10-20 15:27             ` Matthew Heaney
2004-10-21  1:36               ` Matthew Heaney
2004-10-19 12:38   ` Marin David Condic
2004-10-18 16:59 ` Matthew Heaney
2004-10-18 18:02 ` Martin Dowie
2004-10-19 13:06   ` Marin David Condic
2004-10-19 14:51     ` Martin Dowie
2004-10-20 16:20 ` Michael Paus [this message]
2004-10-20 17:15   ` Matthew Heaney
2004-10-20 17:55     ` Michael Paus
2004-10-21 12:33   ` Marin David Condic
  -- strict thread matches above, loose matches on Subject: below --
2004-10-21 13:59 Stephen Leake
replies disabled

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