[comp.lang.pascal] formatting

steve@basser.oz (Stephen Russell) (10/15/89)

In article <2532@hub.UUCP> pete@cavevax.ucsb.edu writes:
>
>The formatting problem goes away if you give everybody a formatter and
>let them run foreign code through it whenever they need to use that
>foreign code. Nobody's ever actually LOOKING at the same code [...]

Unfortunately, this doesn't always work out. Most of the stuff posted
to the sources groups is formatted in a style which I don't like (though
I'm sure its authors think it's fine). It's tempting to just run it
through a formatter to make it look just right for me. Problem is that
when some patches are posted, I'm in trouble. The fact that the author
and I are not "actually LOOKING at the same code" makes patching next
to impossible.

The only solution is to force the rest of the world to adopt my
indenting style - no arguments, ok :-).

rang@cs.wisc.edu (Anton Rang) (10/16/89)

In article <2643@basser.oz> steve@basser.oz (Stephen Russell) writes:
  [ in reference to a suggestion about always reformatting code ]

>[ ... ] Problem is that when some patches are posted, I'm in trouble.
>The fact that the author and I are not "actually LOOKING at the same
>code" makes patching next to impossible.

  The way to fix this is to have a smarter patch system.  After all,
indentation doesn't change the tokens in a Pascal program.  It
shouldn't be *too* hard to write a smarter patch program....
   
+----------------------------------+------------------+
| Anton Rang (grad student)        | rang@cs.wisc.edu |
| University of Wisconsin--Madison |                  |
+----------------------------------+------------------+

dmurdoch@watstat.waterloo.edu (Duncan Murdoch) (10/16/89)

In article <2643@basser.oz> steve@basser.oz (Stephen Russell) writes:
>
>Unfortunately, this doesn't always work out. Most of the stuff posted
>to the sources groups is formatted in a style which I don't like (though
>I'm sure its authors think it's fine). It's tempting to just run it
>through a formatter to make it look just right for me. Problem is that
>when some patches are posted, I'm in trouble. The fact that the author
>and I are not "actually LOOKING at the same code" makes patching next
>to impossible.

I don't see this as a real problem:  if you modify the program, you can't run
the patcher; if you don't modify it, then why bother reformatting it?  If just
to get a readable copy to get some ideas from, then there's no reason to keep
the reformatted version after you've read it - you can always generate it
again from the original, anyways.

Duncan Murdoch

steve@basser.oz (Stephen Russell) (10/16/89)

In article <RANG.89Oct15155002@derby.cs.wisc.edu> rang@cs.wisc.edu (Anton Rang) writes:
>In article <2643@basser.oz> steve@basser.oz (Stephen Russell) writes:
>[ local reformatting makes patching difficult ].
>
>  The way to fix this is to have a smarter patch system.

True; a smarter "patch" program will help. The advantage of lwall's
program is it will patch any text file, so is language independent.
A language-dependent patch would lose this versatility, would need
to be extended for new languages, but would offer some advantages,
of course.

6600pete@ucsbuxa.ucsb.edu (10/17/89)

In article <2643@basser.oz> steve@basser.oz (Stephen Russell) writes:

   In article <2532@hub.UUCP> pete@cavevax.ucsb.edu writes:
   > >The formatting problem goes away if you give everybody a
   formatter and >let them run foreign code through it whenever they
   need to use that >foreign code. Nobody's ever actually LOOKING at
   the same code [...]

   Unfortunately, this doesn't always work out. Most of the stuff
   posted to the sources groups is formatted in a style which I don't
   like (though I'm sure its authors think it's fine). It's tempting
   to just run it through a formatter to make it look just right for
   me. Problem is that when some patches are posted, I'm in trouble.
   The fact that the author and I are not "actually LOOKING at the
   same code" makes patching next to impossible.

   The only solution is to force the rest of the world to adopt my
   indenting style - no arguments, ok :-).

Well... why don't you just keep a foo.pas.orig? Apply the patches and
run THAT through the formatter.

lindsay@comp.vuw.ac.nz (Lindsay Groves) (10/18/89)

This discussion seems to have strayed somewhat from the original question
(what a surprise!), which was to do with whether someone grading student
assignments should deduct marks because the program, though indented in a
consistent manner, was not indented in the way the instructor specified.

The short answer to the question is:  If you are doing grading, you do it the 
way the instructor tells you to.  If his instructions aren't clear, go back
and ask him.

Most of the discussion has addressed the broader issue of whether it is
"right" to penalise students for not conforming to a particular indenting
standard.  There have been various arguments for and against, most of which
make sense in their own context -- but that is often not the context in which
the original question was asked.

I would argue that it depends what kind of course you are teaching and what it
is you really want students to learn.  In an introductory course, the main
aim is to get students to understand the principles of algorithmic problem
solving and to learn a programming language so that they can express solutions
to problems in that language.  I this kind of course, I tell students that it
is important to lay programs out well so that they are readable, I present all
of my programs in a consistent style (not necessarily the same as their text
book), but I would not deduct marks because they did not follow my style or
any other -- only if their programs were difficult to read.

Making them adhere to a particular style at this stage seems to be emphasising
the wrong things.  All of the arguments about standards and having several
people working on the same program are pretty much irrelevant to someone who
is just learning to program.  I even think it is a good thing for them to
think about different styles and play around a bit to see what they like.

When they get on a bit and take software engineering courses and do group
projects -- then they will come to appreciate the value of standards.  In this
kind of course, I tell them about coding standards in lectures and let them
decide what standards (if any) to follow in their project.  They then learn
fast, because it more relevant and more meaningful to them.  At that point (if
not before) they should also be introduced to software tools such as
reformatters.  (The difficulties of applying patches to reformatted programs
is hardly relevant to students just learning to program!)

Another angle on this is that instead of using formatters to tidy up source
files after you've created them, we should be using editors which know enough
about the language to do the indenting etc.  Several universities in NZ are
using LightSpeed Pascal on Macs (we are probably going to go that way next
year).  LightSpeed does all the indenting for you, so the question of
deducting marks for incorrectly formatter programs goes away entirely.  This
means that students can concentrate on the things they are really supposed to
be learning!