comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: "Classes" as packages in Ada
Date: 1999/03/28
Date: 1999-03-28T00:00:00+00:00	[thread overview]
Message-ID: <m3n20xtnf2.fsf@mheaney.ni.net> (raw)
In-Reply-To: 3UU62.124$8X3.638914@news.rdc1.az.home.com

"John Goodsen" <jgoodsen@radsoft.com> writes:

> So my conclusion is that Ada code for an interface is not even
> close in simplicity (from the programmer's point of view) as
> something like:
> 
> public class ObserverEvent {
>     ...
> }
> public interface Observer {
>     public void Update(Observable);
> }
> public interface Observerable {
>     public void AddObserver(Observer);
>     public void RemoveObserver(Observer);
>     public void NotifyObservers(Observer, ObserverEvent).
> }


There are a few variations of the Observer pattern theme in the March 99
ACM patterns archive.

<mailto:patterns@acm.org>
<http://www.acm.org/archives/patterns.html>


The example in the article "Observer Is Subject" has a spec very similar
to what you wrote above:


package Subjects_And_Observers is

   type Root_Subject_Type is
     abstract tagged limited private;

   procedure Notify (Subject : in out Root_Subject_Type'Class);


   type Root_Observer_Type is
     abstract new Root_Subject_Type with private;

   procedure Update (Observer : access Root_Observer_Type) is abstract;


   procedure Attach
     (Observer : access Root_Observer_Type'Class;
      To       : access Root_Subject_Type'Class);

   procedure Detach
     (Observer : access Root_Observer_Type'Class;
      From     : access Root_Subject_Type'Class);
...
end Subjects_And_Observers;


See also my versions of the Mediator pattern, which use the Observer
pattern for their implementation.

I have converted every example in the GoF Design Patterns book to
Ada95.  All the work is archived at the URL above.

You can subscribe to the ACM patterns list by sending the message (body)

subscribe patterns <your full name>


to the ACM mailing-list server.

<mailto:listserv@acm.org>


Matt




      parent reply	other threads:[~1999-03-28  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-11-24  0:00 "Classes" as packages in Ada Samuel Mize
1998-11-24  0:00 ` John Goodsen
1998-11-25  0:00   ` Ed Falis
1998-11-25  0:00     ` John Goodsen
1998-11-25  0:00       ` Robert I. Eachus
1998-11-28  0:00         ` Brian Rogoff
1998-11-30  0:00         ` Robert I. Eachus
1999-03-28  0:00         ` Matthew Heaney
1998-11-27  0:00       ` Larry Kilgallen
1999-03-28  0:00       ` Matthew Heaney [this message]
replies disabled

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