[TUHS] Discuss of style and design of computer programs from a user stand point

David david at kdbarto.org
Sun May 7 03:52:11 AEST 2017


> From: Michael Kjörling <michael at kjorling.se>
> To: tuhs at minnie.tuhs.org
> Subject: Re: [TUHS] Discuss of style and design of computer programs
> 	from a user stand point
> Message-ID: <20170506091857.GE12539 at yeono.kjorling.se>
> Content-Type: text/plain; charset=utf-8
> 
> I would actually take that one step further: When you are writing
> code, you are _first and foremost_ communicating with whatever human
> will need to read or modify the code later. That human might be you, a
> colleague, or the violent psychopath who knows both where you live and
> where your little kids go to school (might as well be you). You should
> strive to write the code accordingly, _even if_ the odds of the threat
> ever materializing are slim at most. Style matters a lot, there.
> 
Interesting, I was going to say about the same thing about the violent psychopath
who has to maintain your code after you leave. When I lectured at UCSD or was
giving talks on style for ViaSat I always said the same thing:

  Whatever you write, the fellow who is going to wind up maintaining it is a known
  axe killer, now released from prison, completely reformed. He learned computer
  programming on MS/DOS 3.1 and a slightly broken version of Pascal. He will be
  given your home phone number and address so if he has any questions about the
  code you wrote he can get in contact with you.

This always got a few chuckles. I then pointed out that whenever anyone gets code
that someone else wrote, the recipient always thinks that they can ‘clean up’ what
is there because the original author clearly doesn’t understand what proper code
looks like.

Over time, I’ve learned that everyone has a style when writing code, just like handwriting
and given enough time, I can spot who the author of a block of code is just from the
indenting, placement of ( and ) around a statement and other small traits.

What makes good code is the ability to convey the meaning of the algorithm
from the original author to all those who come after. Sometimes even the most
unusual code can be quite clear, while the most cleanly formatted and commented
code can be opaque to all.

	David




More information about the TUHS mailing list