:: Re: [DNG] Readable code; making cod…
Top Pagina
Delete this message
Reply to this message
Auteur: Rainer Weikusat
Datum:  
Aan: dng
Onderwerp: Re: [DNG] Readable code; making code more easily writable; Emacs, multifiles-apmod; VUE; Code Bubbles; Lisp; Inform 7; HyperCard and HyperTalk - was Re: "Common knowledge?"-question
Apollia <apollia112@???> writes:
> Rainer Weikusat <rainerweikusat@???> wrote:
>
>> Apollia <apollia112@???> writes:


[...]

>>> I often like to use long, descriptive names for functions and
>>> variables,


[...]

>> combined-list-of-files-in-all-source-folders
>>
>> doesn't really communicate more than 'all-files' or even just 'all' (if
>> the files is evident from the context) would.
>
> Thanks for the feedback! Perhaps as I get more comfortable with
> programming in general I'll stop relying so much on the crutch of overly
> verbose names. I know I overdo it to some extent.
>
> But another thing I like about long, unique, non-generic names is that
> when doing searches, I can more easily find definitely related pieces
> of code, and avoid finding a lot of unrelated pieces of code which
> just happen to use the same generic variable names like "x" or "all".


[...]

A pretty complicated way to express "I think I'm right and you're
wrong." (supposed to apply to all of the text, it took me a few hours to
think through that), however "So do I.".

[next paragraph is a paraphrase of a part of the kernel CodingStyle
document I consider to be 'generally sensible' in this respect]

On it's own a word (or even a phrase) is meaningless. It's always
supposed to be understood in a certain context. Applied to naming in
programs, this means one should consider using rather short names if
there's a lot of context, eg, for local variables, and longer ones if
they have to stand on their own, eg, public functions or global
variables.

[followed by my own, insignificant opinion]

There should be no reason to do global searches for local names. That's
a bit like cutting up people in order to determine what food they
apparently like. In an expression,

combined-list-of-files-in-all-source-folders

is very unwieldly. Imagine this as

(if
  (<= 
    (-
      (* number-of-files-in-all-source-folders
        average-number-of-lines-per-file-in-source-folders)
      (* number-of-files-in-all-letter-folders
         average-number-of-lines-per-file-in-letter-folders)))
   'write-some-more-code-in-future
   'reply-to-a-few-letters)


[the first silly contrived example I could come up with]

Almost all of this is letters of names and the code itself is dwarfed by
them. But the names, no matter how expressive, only communicate intent
and not facts. And that's also a lot of text to express very little, ie,
a program written in this way will either end up being of epic
proportions or accomplish very little.