[Oberon] NW programming style

Lars noreply at z505.com
Mon Sep 5 11:59:24 CEST 2016


On Mon, July 11, 2016 11:45 am, Richard Hable wrote:
> Am 2016-07-11 um 17:13 schrieb Skulski, Wojciech:
>
>
>> I was always amused by NW advocating high level programming, using
>> named constants rather than hard coding the numbersg.
>
> I don't think the master of simplicity ever advocated using named
> constants in cases like this. It is not difficult to count to three
> when  looking at the mouse keys

So, if you had a program with just three procedures, a simple utility, it
would be better to make the program like this:

PROCEDURE ONE;
BEGIN
END;


PROCEDURE TWO;
BEGIN
END;


PROCEDURE THREE;
BEGIN
END;

BEGIN
  ONE;
  TWO;
  THREE
END.

Rather than being sensible and doing this:

PROCEDURE WriteToFile;
BEGIN
END;

PROCEDURE CloseFile;
BEGIN
END;

PROCEDURE PrintToScreen;
BEGIN
END;


BEGIN
  WriteToFile;
  CloseFile;
  PrintToScreen
END.

Because after all, one, two, three, is simpler.. right? But what does one,
two, three, even mean? What does it say? nothing at all.. it's useless
information... it could mean anything, or nothing at all... whereas
descriptive names mean something in code while reading it. So you would
prefer a program that just said ONE TWO THREE instead of being
descriptive? Why, if procedures are named properly, shouldn't named
constants also be named properly?

The only time something shouldn't be named, is a variable such as "i" like
a loop counter, where i just means a loop integer or a loop number.... 
But for named constants... why in the world would you be satisfied with
one, two, three...... I don't know...

If procedures should be named, why not other things like variables and
constants?


More information about the Oberon mailing list