'goto', as an indicator of good language

H. S. Teoh hsteoh at qfbox.info
Fri Sep 9 01:20:09 UTC 2022


On Fri, Sep 09, 2022 at 12:26:44AM +0000, max haughton via Digitalmars-d wrote:
> On Thursday, 8 September 2022 at 22:49:05 UTC, Walter Bright wrote:
> > goto can be handy to avoid needing to refactor a bunch of code
> > when fixing a problem.
> > 
> > The refactoring can come later in its own PR.
> 
> It almost never does though, let's be realistic.

IME, typically code stinks come about this way:

1) Original code is reasonably clean and well-written.

2) A critical bug is discovered 2 days before the release deadline.

3) In the mad rush to get the release out the door, Good-Hearted
   Programmer #1 pulls an all-nighter to fix the bug by any means
   possible. He comforts himself, "I will clean up this messy hack code
   after the release."

4) Thanks to Good-Hearted Programmer #1's heroic efforts, the release
   makes it out the door on time.  There is celebration, and
   Good-Hearted Programmer #1 says to himself, I'll relax for a couple
   o' days to recover from the release.

5) But Just as Good Hearted Programmer #1 is about to clean up the hack
   code, PTB walks in and hands him High Priority Project X that has to
   be done by last week.  He gets totally occupied with Project X and
   forgets about cleaning up the code.

6) Meanwhile, another release deadline looms, and another bug is
   discovered in the code. Good Hearted Programmer #2 is assigned to fix
   it, and, not understanding the hack that GHP#1 has done, says to
   himself, "There's no time to figure this out, I'll just patch over
   the code and redo the fix properly after the release."

Steps (4)-(5) are repeated, now to GHP#2, and (6) is repeated with
GHP#3.  Soon, GHP#1, GHP#2, and GHP#3 have moved on to other projects or
to a different company altogether.  And so layer upon layer of hacks and
bandages are accumulated on top of the code, the well-intentioned
cleanups never happen.  Soon, so much cruft has accumulated that nobody
knows how to clean it up anymore. Instead, the bugs and quirky
behaviours are worked around and patched over, and customers begin
relying on the quirky behaviour, further cementing it forever.


T

-- 
MACINTOSH: Most Applications Crash, If Not, The Operating System Hangs


More information about the Digitalmars-d mailing list