From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1108a1,fd96375b28b3103b X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,fd96375b28b3103b X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: "Classes" as packages in Ada Date: 1999/03/28 Message-ID: #1/1 X-Deja-AN: 460087527 References: <73f0p1$4iu8$1@prime.imagin.net> <1103_911962898@DZOG-CHEN> <3UU62.124$8X3.638914@news.rdc1.az.home.com> NNTP-Posting-Date: Sun, 28 Mar 1999 11:34:32 PDT Newsgroups: comp.lang.ada,comp.object Date: 1999-03-28T00:00:00+00:00 List-Id: "John Goodsen" 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. 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 to the ACM mailing-list server. Matt