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: 103376,386670df95abccf1 X-Google-Attributes: gid103376,public From: fraser@sinopsis.com Subject: Re: ANNOUNCE: Abstract Factory posted to ACM patterns archive Date: 1999/03/09 Message-ID: <7c3mq2$ns$1@remarQ.com>#1/1 X-Deja-AN: 453046756 References: <7bmcb5$jkf$1@nnrp1.dejanews.com> X-Complaints-To: newsabuse@remarQ.com X-Trace: 921001602 KZBGBQC4S164892E1C usenet78.supernews.com Organization: Vegetarian Ada Programmers Newsgroups: comp.lang.ada Originator: fraser@titanic Date: 1999-03-09T00:00:00+00:00 List-Id: paene lacrimavi postquam jerry@jvdsys.stuyts.nl (Jerry van Dijk) scribavit: >With other words, pointers seem to be the essential tool for using this >design method. Although the thinking behind the pattern idea is powerful by >its rigid application, whenever I try to apply it, I end up with programs >that seem to become impregnable through the heavy use of indirection, >overloading and dispatching. Gone is the "clear and elegant" (for lack of >better wording) ADT based structure I like so much in Ada. I had no idea I was using a factory when I designed a symbol table class, but there you go. I have a root class, with abstract versions of Insert, First, Next, Exists, that sort of thing. Actually, there's another hierarchy of constraint objects that let you search for more specific things, but anyway. Currently, there are two derived types; one for a hashed symbol table, and one for a linked list table. Once you've created a table using the appropriate function in the child package, you don't need to worry about which version you're using, which makes using it much nicer. Certainly, they're implemented as access types, but I found that Ada 95's support for this paradigm made that practically invisible. In fact, it *is* invisible. Consider: T : Table := Tables.Hashed.New_Table ( ... ); E : Table_Entry; Insert (T, E); E := First (T, "x"); E := Next (T, "x"); Sure, there's a "type Table is access all Root_Table_Type'Class" in one of the specs, but the only thing you have to know is that Table is declared somewhere. Dispatching is obviously essential to the way this works, but I don't see how you use the Factory pattern without it. Fraser. (change the i's to y's to get my real email address)