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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,a8d137db7a5f6c81 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!newspeer.monmouth.com!newsgate.cistron.nl!feeder1.cambrium.nl!feed.tweaknews.nl!216.196.110.149.MISMATCH!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!peer-uk.news.demon.net!kibo.news.demon.net!news.demon.co.uk!demon!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: OO problem: Performing actions on messages (very long, sorry) Date: 10 Jan 2005 21:54:48 +0000 Organization: Pushface Sender: simon@smaug.pushface.org Message-ID: References: <1103723394.299024.314670@c13g2000cwb.googlegroups.com> NNTP-Posting-Host: pogner.demon.co.uk Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: news.demon.co.uk 1105394129 27771 62.49.19.209 (10 Jan 2005 21:55:29 GMT) X-Complaints-To: abuse@demon.net NNTP-Posting-Date: Mon, 10 Jan 2005 21:55:29 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.1 Xref: g2news1.google.com comp.lang.ada:7626 Date: 2005-01-10T21:54:48+00:00 List-Id: "per" writes: > I'm new to Ada (but not to OO). I'm having trouble designing a > system, or at least a key part of it. (I have a few alternative > non-tested solutions but I don't get why this doesn't work.) And I'd > like to do it "by the book" in nice OO Ada coding style. Nothing wrong with that, but you do need to get the right classes (analyse the right problem? -- UML background coming out there!). Seems to me you have a number of message specs; a message spec consists of a (ordered) set of field specs; a field spec consists of a type (and perhaps a size). It's here that you're going to hit "simple" Ada types. I'm not sure where your actions come in; are they related to a field type, to a field in a message type, or a field in a particular message? Anyway, given a set of field specs in a message spec you can build up a particular message (consisting of field _values_ corresponding to the specs). And the action can do its thing when appropriate, The message would (in my view) have a lot more to it than the bare bytes that get sent to the equipment under test (I suspect you think so too). What might be appropriate here is a convert-to-byte-stream operation. The advantage of a data-driven approach like this, if you can swing it, is that adding new messages is only a matter of adding new message type definitions, which are just data about messages. Just my 2p --