comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada OOP alternatives?
Date: Fri, 25 Jul 2008 15:28:33 +0200
Date: 2008-07-25T15:28:33+02:00	[thread overview]
Message-ID: <en861ln1rnyi$.1je4v1x4rs1ce.dlg@40tude.net> (raw)
In-Reply-To: 48899335$0$18824$9b4e6d93@newsspool2.arcor-online.net

On Fri, 25 Jul 2008 10:47:49 +0200, Georg Bauhaus wrote:

[...] 
> Suppose you try to use an IDE in place of "separate",
> to hide away the details of Special_Case. Then the dependences
> on the with'ed package Ada.Text_IO and on All_Kinds_of_Things_Neccessary
> will have to be listed for the entire package.

Yes, but it would not change dependencies. The difference is merely visual,
wth-es appears in the parent body. So what? I never read with clauses. They
are semantically useless, impose a maintenance problem (GNAT does not
always warn about superfluous with's).

Better, there should be a "without" clause/pragma (:-))

> Observation 2:
[...]
> What amount of work is needed to make this reusable?

I cannot tell, because the example is ill-designed in my eyes. IMO, it
should be designed as a [private] child with:

   type Special_T is new T with ...; -- The "special case" is this
   overrides procedure Op (Item : T); -- This is an implementation of

So, yes, an ADT, even if it is a singleton today.

> Granted, there are cases when a child package seems a
> much better choice. For example, when the special communications
> procedure needs to maintain state information that is of
> no concern to any other subprogram anywhere.

Bad, very bad, design. Only objects should have states. Global variables is
a no-no. There cannot be stateful procedures otherwise than impure, with
global variables.

>>> Why, e.g., build an entire type when a single procedure
>>> is sufficient, and will be sufficient in the future?
>> 
>> How can you know that?
> 
> Sometimes the future of a program is known.  For example,
> known to end, because the strange device is no longer produced
> and the support has ended.  The special case procedure dies
> with the special case device/program.

Even if a strange device is no more produced, it is still used by
customers. And customer requirements change. Bad design never pays off.

>>> Many languages have a function type
>>> built in, functions are objects.
>> 
>> But not in the sense of a stateful object of OO.
> 
> Yes, there are function objects in the sense of a stateful object
> of OO.

Hmm, if you mean active objects, like Ada task types, then observe that
they are not procedures. A task type has methods (entry points), which are
procedures.

If you mean a procedural abstraction of some external stateful thing, like
random generator, then it is a bad design. The state should be explicitly
bound to some visible object to which the procedure would be applied.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-07-25 13:28 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-15 20:38 Ada OOP alternatives? raould
2008-07-16  0:15 ` Robert A Duff
2008-07-16  6:33   ` Georg Bauhaus
2008-07-16  9:54     ` Alex R. Mosteo
2008-07-16 13:03       ` Dmitry A. Kazakov
2008-07-16 14:07       ` Robert A Duff
2008-07-16 18:11         ` (see below)
2008-07-17  0:05           ` Robert A Duff
2008-07-17  0:43             ` (see below)
2008-07-17  1:36               ` Robert A Duff
2008-07-17 11:07                 ` (see below)
2008-07-17 16:45                   ` Robert A Duff
2008-07-17 12:00                 ` Dmitry A. Kazakov
2008-07-17 16:50                   ` Robert A Duff
2008-07-17 18:56                     ` Dmitry A. Kazakov
2008-07-18 12:54                       ` Robert A Duff
2008-07-18 13:36                         ` Dmitry A. Kazakov
2008-07-17 23:27                 ` Randy Brukardt
2008-07-18 12:45                   ` Robert A Duff
2008-07-18 23:22                     ` Randy Brukardt
2008-07-22 20:32                 ` Adam Beneschan
2008-07-22 22:18                   ` Ludovic Brenta
2008-07-23  9:25                     ` Alex R. Mosteo
2008-07-22 23:35                   ` Randy Brukardt
2008-07-23  7:56                   ` Dmitry A. Kazakov
2008-07-23 21:04                     ` Robert A Duff
2008-07-24  7:07                       ` stefan-lucks
     [not found]                       ` <5ob7w7usrc74$.kms2e1vqs4k0.dlg@40tude.net>
     [not found]                         ` <48883529$0$18826$9b4e6d93@newsspool2.arcor-online.net>
     [not found]                           ` <ygdmhl22lzh4$.1dx98hja6p2o6.dlg@40tude.net>
     [not found]                             ` <48883f41$0$18829$9b4e6d93@newsspool2.arcor-online.net>
     [not found]                               ` <6i1s0y8eeka.121ek9qcgunha$.dlg@40tude.net>
     [not found]                                 ` <48885757$0$18818$9b4e6d93@newsspool2.arcor-online.net>
2008-07-24 12:48                                   ` Dmitry A. Kazakov
2008-07-25  8:47                                     ` Georg Bauhaus
2008-07-25 13:28                                       ` Dmitry A. Kazakov [this message]
2008-07-25 16:24                                         ` Georg Bauhaus
2008-07-25 17:55                                           ` Dmitry A. Kazakov
2008-07-26  5:05                   ` Jeff Koftinoff
2008-07-16 14:03     ` Robert A Duff
2008-07-16 14:29       ` Dmitry A. Kazakov
replies disabled

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