comp.lang.ada
 help / color / mirror / Atom feed
From: <MARTIN%SCRANTON.BITNET@vma.cc.cmu.edu>
Subject: Ada micro Style for Programs in Introductory Textbooks
Date: Fri, 6 Sep 91 12:48 EST	[thread overview]
Message-ID: <9109061645.AA02727@ajpo.sei.cmu.edu> (raw)

Richard Pattis writes:
>Date: 5 Sep 91 19:05:51 GMT
>From: june.cs.washington.edu!pattis@beaver.cs.washington.edu  (Richard Pattis)
>Subject: Ada micro Style for Programs in Introductory Textbooks
>Message-ID: <1991Sep5.190551.8272@beaver.cs.washington.edu>

  I recently received some reviews for a CS 1 (Introduction to Programming) in
Ada textbook. I was criticized (to varying degrees) for not typesetting my Ada
code according to the standard established in the LRM.
---stuff deleted---

>  1) Ada's words (whether reserved words or predefined identifiers - see
>point 2) should be easily identified; they are the landmarks to navigating
>through programs.  The LRM uses bold-face, but that is not an option for
>students who write programs using standard text editors. I want to present
>code in the book using a style that the students can emulate in their
>programs.  Upper-case words stand out best.

Reserved words provide the structure of the program and must stand out.
Having taught and used both C and Modula-2 which are case-sensitive with
differing requirements on the case for reserved words, I believe that
either all caps (Modula-2) or all lc (C) are equally effective if used
consistently and if they contrast with user-defined words.

>  2) To beginners, there is little difference between Ada's reserved words
>and the predefined identifiers. If I had to place reserved words, predefined
>identifiers, and user defined identifiers into two categories, I would opt to
>place the first two together (have a built-in meaning) rather than the second
>two (the user can choose the meaning).  Certainly this seems true for
identifiers like INTEGER and CONSTRAINT_ERROR. Even for identifiers like POS
>(where there is a good chance a beginner will declare a variable with this
>name), writing POS when used as an attribute (something from Ada) and Pos when
>used as a user declared identifier seems reasonable.

Predefined types (integer, float, etc.) seem to be comfortable using the
style of reserved words but I find myself using user-defined style when I
program as it seems more comfortable to have all the types consistent rather
than distinguishing between pre-defined and user-defined in a series of
declarations.  Text book writers have to worry about such problems but I
tell my students to try to be consistent but that either is acceptable.
C gives no helpful hints as I am convinced that K&R did not have a shift
key when they developed it.

I/O functions should be mixed case.  Pre-defined library units are neither
fully pre-defined nor fully user-defined.  Text book writers need to face
the fact that we now have a third category that, with the concept of re-
usable code becoming an essential consideration, needs to be better handled.

>  3) Mixed case identifiers (user defined) are easier to read than all upper-
>case or all lower-case (even with underscores).  Compare Student_Count and
>StudentCount with STUDENT_COUNT and STUDENTCOUNT. So the problem specific
>words (which are often plentiful, long, and descriptive) should be written in
>mixed case.

I prefer Mixed_Case with underscores.  Long words without breaks (underscores)
make a program look awkward.  Are there still printers out there that only
print CAPS?  We used to have one.  Made reading Modula-2 code difficult.

A consistent style is essential for program clarity.  We use a Language
Sensitive Editor that forces tokens to adhere to our chosen style.  For
Modula-2, it forced CAPS and we adapted our Pascal LSE to produce CAPS.
The LSE for Ada uses lc tokens and it was easier to go with that than to
modify it.  We did modify the Pascal LSE to produce lc tokens to match the
Ada LSE better when we switched to Ada as our primary language.  Both
styles in Pascal were very effective.  Consistency is really the point.

Dennis S. Martin
University of Scranton
martin@jaguar.uofs.edu
martin@scranton.bitnet

             reply	other threads:[~1991-09-06 17:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1991-09-06 17:48 MARTIN%SCRANTON.BITNET [this message]
  -- strict thread matches above, loose matches on Subject: below --
1991-09-10 16:36 Ada micro Style for Programs in Introductory Textbooks Mr. D. Harter
1991-09-10  3:47 Robert I. Eachus
1991-09-09 15:31 Ada micro style for programs in introductory textbooks Frank Pappas
1991-09-06 21:09 Ada micro Style for Programs in Introductory Textbooks david.c.willett
1991-09-06 19:56 munck
1991-09-06 18:06 agate!bionet!ucselx!sol.ctr.columbia.edu!spool.mu.edu!tulane!uno.edu!JNCS
1991-09-06 12:50 europa.asd.contel.com!darwin.sura.net!noc.sura.net!haven.umd.edu!cs.wvu.w
1991-09-06 10:25 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!caen!uvaarpa!vger.nsu.edu!g_
1991-09-06  2:35 cis.ohio-state.edu!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!jpl-d
1991-09-05 23:52 munnari.oz.au!yoyo.aarnet.edu.au!sirius.ucs.adelaide.edu.au!chook.cs.adel
1991-09-05 21:53 David Eichmann
1991-09-05 21:00 Bill Yow
replies disabled

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