comp.lang.ada
 help / color / mirror / Atom feed
From: weber@lglsun.epfl.ch (Mats Weber)
Subject: Re: Naive question about system dependencies
Date: 17 Sep 1994 16:23:05 GMT
Date: 1994-09-17T16:23:05+00:00	[thread overview]
Message-ID: <35f559$mad@info.epfl.ch> (raw)
In-Reply-To: Cw8GK2.M9y@inmet.camb.inmet.com

In article <Cw8GK2.M9y@inmet.camb.inmet.com>
stt@spock.camb.inmet.com (Tucker Taft) writes:

> Some people use the C preprocessor (or equivalent) with Ada source
> code.  However, in our environment we have found it is more
> maintainable to avoid using the preprocessor approach, and define
> interfaces to isolate target/host independent code from target/host 
> dependent code, and then have separate bodies to implement
> the interface for each target/host.

> Although this might seem like more work, in the long run
> it vastly simplifies the process of moving to a new target
> or host, and keeps the code much more readable than when
> ifdef's and associated target dependences are littered around the code.

I totally agree. We have been doing this for many Ada components
(common SQL interface for various OS's and DB vendors, common interface
to UNIX Sockets/DECnet, etc.).

In many cases, a single package specification with different bodies
solves the problem. In other cases, the private part of the package
needs to be different in different variants (this means duplication of
the spec in Ada 83, Ada 9X has significant imporvements for handling
such cases).

Using a good file naming convention helps a lot in managing the
different versions. We use something like this:

sql_interface.ads                 (common package spec)
sql_interface-oracle-vms.adb      (body for Oracle under VMS)
sql_interface-sybase-unix.adb     (body for Sybase under UNIX)

Despite the amount of code duplication, I prefer this to a preprocessor
approach.



  reply	other threads:[~1994-09-17 16:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1994-09-15  6:32 Naive question about system dependencies Howard Holm
1994-09-16 17:28 ` Tucker Taft
1994-09-17 16:23   ` Mats Weber [this message]
1994-09-19 12:05     ` Ted Dennison
1994-09-19 14:39       ` Cyrille Comar
1994-09-19 15:00       ` Norman H. Cohen
1994-09-20  9:02       ` Stephen J Bevan
     [not found]     ` <85B716C4188@annwfn.com>
1994-09-22 13:33       ` David Kehs
1994-09-22 14:15       ` Robert Dewar
1994-09-23  4:34         ` R. William Beckwith
1994-09-22 14:54       ` Norman H. Cohen
  -- strict thread matches above, loose matches on Subject: below --
1994-09-19 14:48 Bob Crispen
replies disabled

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