comp.lang.ada
 help / color / mirror / Atom feed
From: Robert Dewar <robert_dewar@my-deja.com>
Subject: Re: Escape Sequences in Strings
Date: Sat, 13 Jan 2001 18:36:33 GMT
Date: 2001-01-13T18:36:33+00:00	[thread overview]
Message-ID: <93q77h$rr6$1@nnrp1.deja.com> (raw)
In-Reply-To: ZSS76.120778$A06.3893142@news1.frmt1.sfba.home.com

In article
<ZSS76.120778$A06.3893142@news1.frmt1.sfba.home.com>,
  tmoran@acm.org wrote:
> In article
> <93objj$guk$1@nnrp1.deja.com>,
>   robert_dewar@my-deja.com wrote:
>
> >   Ada.Text_IO.Put (Home_Cursor & "hello there!");

You are completely (perhaps deliberately? :-) misreading
what I wrote. I was just reacting to your code that embedded
a peculiar constant string, and using the above statement to
illustrate that if you do want to send strange strings to
Put, they should be sent using named constants, that's all!

> If I saw this in real code, I would be unhappy.  It assumes:

> a) that cursor positioning is done by sending a special
> string

Yes, indeed it assumes that, and that is true at the lowest
level in some systems, so at the lowest level, you will see
code like this.

> b) that this greeting string should always be placed at
> cursor home position

Sure, that is the assumption in the example, if it is not true
of your case, you have to change the example.

> c) that the string will always be "hello there!".

Sure, that is the assumption in the example, if it is not true
of your case, you have to change the example.

Note: for my own taste, I hate to present-by-example, and I
hate examples, but my experience is most people like examples.
For instance, most people want MORE examples in the RM, I
regard them as irritating redundant (well hopefully redundant)
non-normative junk :-)

> A more thorough application of information hiding would
> have a low level routine "Home_Cursor"

I was of course just showing the kind of code that might
appear in low level routines.

> used by a mid-level
> routine "Move_To_Greeting_Field" which would be followed by
> output of a Greeting string from a set of message string
> constants.

Well such a structure might be appropriate depending on the
application. If the program at hand has the following spec,
as a homework assignment might:

Print "hello there!" at the home position on your screen,

then this amount of structure would be overkill. You do
sometimes see students doing this kind of thing (making
mountains out of molehills :-)

But Tom, the real point that I was making is that REGARDLESS
of the structure or requirements of your program, NEVER EVER
put junk constants in the code, that was the ONLY point I was
making, I was not writing a treatise on how to do the abstract
top down structure of a program that puts information on the
screen.

I really think it is bad practice to EVER write even example
code that has junk constants in it, as your example did. Yes,
it is easy to do when we are being lazy, but it sets a bad
example (I certainly have done this in examples in the past,
if you go through my own posts, but that does not make it
right).

I find all the time that people put junk constants in code.

MINIMAL (the language which I designed solely for the purpose
of writing one program, namely MACRO-SPITBOL) is the only
language I know that completely forbids constants except in
constant declarations.

That's a little fierce, because constants like 1 and 0, and
perhaps 2 can reasonably appear in that form, and it is also
OK to use constants which are fudnamental to the problem in
some cases e.g. 7 for days of the week, but even there naming
the 7 as Days_Per_Week can clarify code.


Sent via Deja.com
http://www.deja.com/



  reply	other threads:[~2001-01-13 18:36 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-11-15  0:00 Escape Sequences in Strings Jean Cohen
2000-11-15  0:00 ` Marin David Condic
2000-11-16  0:00   ` Ada Streams usage (was Escape Sequences in Strings) Marc A. Criley
2000-11-16  0:00     ` Marin David Condic
2000-11-16  0:00       ` Ted Dennison
2000-11-16  0:00         ` Marin David Condic
2000-11-16  0:00           ` Ted Dennison
2000-11-16  0:00             ` Marin David Condic
     [not found]     ` <igh81t8b3hdrsc167do6qr0h1joa73c1jr@borpin.co.uk>
2000-11-18  0:00       ` Marin David Condic
2000-11-18  0:00         ` David Kristola
2000-11-19  0:00           ` Marin David Condic
2000-11-19  0:00             ` Marin David Condic
2000-11-20  0:00               ` Brian Orpin
2000-11-20  0:00                 ` Marin David Condic
2000-11-19  0:00         ` Ted Dennison
2000-11-19  0:00           ` Marin David Condic
2000-11-19  0:00             ` Robert Dewar
2000-11-20  0:00               ` Marin David Condic
2000-11-21  0:00                 ` Robert Dewar
2000-11-20  0:00               ` Randy Brukardt
2000-11-21  0:00                 ` Ted Dennison
2000-11-21  0:00                   ` Randy Brukardt
2000-11-21  1:31                 ` Robert Dewar
2000-11-21  1:33                 ` Robert Dewar
2000-11-21  0:00                   ` Randy Brukardt
2000-11-22  5:00                     ` Robert Dewar
2000-11-19  0:00             ` Ted Dennison
2000-11-19  0:00               ` Robert Dewar
2000-11-15  0:00 ` Escape Sequences in Strings Preben Randhol
2000-11-15  0:00 ` John English
2000-11-15  0:00   ` Robert Dewar
2000-11-15  0:00     ` Ehud Lamm
2000-11-16  0:00       ` John English
2000-11-16  0:00         ` Tarjei T. Jensen
2000-11-16  0:00           ` Ken Garlington
2000-11-16  0:00             ` Keith Thompson
2000-11-16  0:00             ` Marin David Condic
2000-11-16  0:00         ` Marin David Condic
2001-01-12 13:18 ` Andrew Hately
2001-01-12 20:03   ` Keith Thompson
2001-01-18  8:29     ` Lao Xiao Hai
2001-01-18 15:22       ` Robert Dewar
2001-01-18 22:43         ` Randy Brukardt
2001-01-21 11:54         ` Dale Stanbrough
2001-01-21 22:35           ` directly accessing DOS screen memory (was: Re: Escape Sequences in Strings) Jeffrey Carter
2001-01-12 19:37 ` Escape Sequences in Strings tmoran
2001-01-13  1:38   ` Robert Dewar
2001-01-13  6:48     ` tmoran
2001-01-13 18:36       ` Robert Dewar [this message]
2001-01-16  3:30         ` Examples in Docs, was " peter_richtmyer
2001-01-16  5:42           ` Robert Dewar
2001-01-16 20:44             ` mark_lundquist
2001-01-16 22:43               ` Larry Kilgallen
2001-01-17 15:06                 ` mark_lundquist
2001-01-17  2:25               ` Robert Dewar
2001-01-17 15:28                 ` mark_lundquist
2001-01-17 16:20                 ` Brian Rogoff
2001-01-17 18:04                   ` Wayne Lydecker
2001-01-17 19:23                     ` BSCrawford
2001-01-18  0:15                       ` Jerry Petrey
2001-01-19  0:01                     ` tmoran
2001-01-18  3:44                   ` Robert Dewar
2001-01-18 16:45                     ` Brian Rogoff
2001-01-18 19:53                       ` Robert Dewar
2001-01-18 22:58                         ` Georg Bauhaus
2001-01-19 16:40                           ` Robert Dewar
2001-01-19  7:49                         ` Learning methods Anders Wirzenius
2001-01-19 18:57                         ` Examples in Docs, was Re: Escape Sequences in Strings mark_lundquist
2001-01-21 12:05                         ` Dale Stanbrough
2001-01-21 15:35                           ` Robert Dewar
2001-01-17 22:10                 ` Matthew Woodcraft
2001-01-18  3:52                   ` Robert Dewar
2001-01-16 16:06           ` Examples in Docs Robert C. Leif, Ph.D.
2001-01-16 21:29             ` mark_lundquist
2001-01-18  0:50               ` Randy Brukardt
2001-01-18 16:46                 ` mark_lundquist
2001-01-18 17:24               ` J. David Bryan
2001-01-17  2:43             ` Robert Dewar
2001-01-17 21:17               ` Robert C. Leif, Ph.D.
2001-01-16 20:01           ` Examples in Docs, was Re: Escape Sequences in Strings mark_lundquist
2001-01-17 10:59             ` Peter Richtmyer
2001-01-19 18:55               ` mark_lundquist
2001-01-20 14:24                 ` Robert Dewar
2001-01-20 14:36                   ` Preben Randhol
2001-01-20 15:00                     ` Robert Dewar
2001-01-21 11:24                       ` Preben Randhol
2001-01-22 14:47                         ` Ted Dennison
2001-01-22 20:08                           ` Preben Randhol
2001-01-22 20:14                             ` Preben Randhol
2001-01-20 19:02                   ` Stephen Leake
2001-01-20 19:50                     ` Georg Bauhaus
2001-01-21 11:35                     ` Preben Randhol
2001-01-22 23:58                   ` Mark Lundquist
2001-01-27  1:43                   ` Increasing the readability of Ada was RE: Examples in Docs Robert C. Leif, Ph.D.
  -- strict thread matches above, loose matches on Subject: below --
2000-11-16  0:00 Escape Sequences in Strings Jean Cohen
replies disabled

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