comp.lang.ada
 help / color / mirror / Atom feed
From: "Nick Roberts" <nickroberts@callnetuk.com>
Subject: Re: Programming for the World in Ada95
Date: 2000/02/16
Date: 2000-02-16T00:00:00+00:00	[thread overview]
Message-ID: <38aaf154@eeyore.callnetuk.com> (raw)
In-Reply-To: m3n1p13cmy.fsf@ns59.infomatch.bc.ca

I was going to write an extensive reply to this one, but (I hear you sigh
with relief ;-)  I've cut it down to the following brief recommendations.

1. Introduce one package which declares an abstract root tagged type to
represent a piece of text, and a function to turn the object into actual
(Unicode) text. E.g.:

    package International.Text is

        type Root_Text_Piece is abstract tagged private;

        function Image (Piece: in Root_Text_Piece) return Wide_String is
abstract;

    end;

2. Derive types (in child or other packages, as appropriate) which
correspond to actual text messages. You must implement the 'Image' function
for each. Use an enumerated type as the basic message selector, and have a
derived type (its extension part) contain a component of this enumerated
type. The type can be further parametised in the same way, as necessary.

You can often avoid having to parameterise things too much by recasting your
output in a form which moves the parametised bits (e.g. numbers) out from
being embedded in the text. For example, instead of saying "there were 16
errors, of which 9 matter", you could say "Total number of errors:      16"
on one line, and "Number of critical errors:       9" on the next line,
perhaps. This style often tends to be neater, easier to read, easier to
program, easier to maintain and change, and generally avoids the necessity
for messing around with singular and plural forms.

3. Introduce a package (maybe generic) which implements message retrieval
from a configuration file or (much better) a database table. If your project
is divided into separate modules, being developed independently to some
extent (or simply if the program is very large), make sure you have
facilities for each module's person/team to add and delete messages to/from
the file/table independently of one another. Add a package that allows you
to list the enumeration literals that are message selectors against their
corresponding file/table messages (and keys). Maybe add 'fallback' code that
uses an internal message table in the event the configuration file/table
cannot be opened.

--
Nick Roberts
http://www.adapower.com/lab/adaos








      parent reply	other threads:[~2000-02-16  0:00 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-14  0:00 Programming for the World in Ada95 John J Cupak Jr
2000-02-14  0:00 ` Larry Kilgallen
2000-02-16  0:00   ` Robert A Duff
2000-02-14  0:00 ` Ehud Lamm
2000-02-14  0:00 ` Gautier
2000-02-15  0:00 ` Jean-Pierre Rosen
2000-02-15  0:00   ` Marin D. Condic
2000-02-15  0:00     ` Ray Blaak
2000-02-16  0:00       ` Larry Kilgallen
2000-02-16  0:00       ` Pascal Obry
2000-02-16  0:00       ` Pascal Obry
2000-02-16  0:00         ` Ray Blaak
2000-02-16  0:00       ` Nick Roberts [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