comp.lang.ada
 help / color / mirror / Atom feed
From: Ingo Marks <nospam_adv@region-nord.de>
Subject: Re: New Software Forum
Date: Wed, 18 Sep 2002 19:46:01 +0200
Date: 2002-09-18T19:46:01+02:00	[thread overview]
Message-ID: <amae2n$q5m$05$1@news.t-online.com> (raw)
In-Reply-To: ba162549.0209180607.1c79a6a5@posting.google.com

Kevin Cline wrote:

> Preben Randhol <randhol+news@pvv.org> wrote in message
> news:<slrnaoeprn.vb.randhol+news@kiuk0156.chembio.ntnu.no>...
>> On Tue, 17 Sep 2002 18:41:43 +0200, Ingo Marks wrote:
>> > Ingo Marks wrote:
>> > 
>> > or even this way :-)
>> >  
>> > Put_Line ("Iteration" & Num &
>> >           " Result:"  & Result &
>> >           " Time:"    & Elapsed_Time);
>> 
>> Well now we are borderlining the poor readability. In the previous
>> version I could at least know that Elapsed_Time was a Duration here it
>> can be anything. This is one of the great features of Ada that it is so
>> self-documenting.
> 
> This version is easier to read and easier to maintain.  I don't need to
> know the type of Elapsed_Time to understand this statement, and the
> compiler already knows the type and shouldn't need to be told again.
> Repeating the type here reduces readability and makes the code more
> sensitive to a change in the type of Elapsed_Time.

The compiler doesn't need extra specification but an unbiased reader of 
your source would appreciate it.

For myself I always use the short form for integer (or ranges of it) only. 
So I would prefer

Put_Line ("Iteration" & Num &
          " Result:"  & Result &
          " Time:"    & Duration'Image(Elapsed_Time));

If it is inevitable that the type of Elapsed_Time may change in future then 
it could be good idea to define a subtype:

subtype My_Duration is Duration;

Put_Line ("Iteration" & Num &
          " Result:"  & Result &
          " Time:"    & My_Duration'Image(Elapsed_Time));

If you have to change the type you just need to change one line (hopefully).

Regards,
Ingo




  reply	other threads:[~2002-09-18 17:46 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-09-14 15:33 New Software Forum Jim Rogers
2002-09-15 16:57 ` Daniel Dudley
2002-09-15 18:29   ` Marc Spitzer
2002-09-15 19:22     ` Jim Rogers
2002-09-15 19:33       ` Jim Rogers
2002-09-15 23:27         ` CodeMage
2002-09-16 16:43           ` Adrian Hoe
2002-09-16 18:48           ` sk
2002-09-16 23:43           ` Keith Thompson
2002-09-17  7:38             ` CodeMage
2002-09-16  1:17       ` Jeffrey Carter
2002-09-16 13:51         ` Jim Rogers
2002-09-17  4:27           ` Daniel Dudley
2002-09-17 13:00 ` Ingo Marks
2002-09-17 13:35   ` Preben Randhol
2002-09-17 16:39     ` Ingo Marks
2002-09-17 16:41       ` Ingo Marks
2002-09-17 17:33         ` Preben Randhol
2002-09-17 19:07           ` Ingo Marks
2002-09-17 21:03             ` Simon Wright
2002-09-18 13:04           ` Stephen Leake
2002-09-18 13:38             ` Preben Randhol
2002-09-28 16:57               ` Richard Riehle
2002-09-18 14:07           ` Kevin Cline
2002-09-18 17:46             ` Ingo Marks [this message]
2002-09-18 10:09   ` Ingo Marks
replies disabled

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