3 ms·
I've always held that if you name your methods and variables right, many lines of code can be read as sentences. When describing the fetchmail config syntax, E
by LukeShu 15y ago
I've always held that if you name your methods and variables right, many lines of code can be read as sentences.
When describing the fetchmail config syntax, ESR commented that you should be weary of making something too much like natural language and too complex, but that he added certain optional tokens that get filtered out to make the syntax more readable.
Like the `wtf' command (from BSD?). It tells you what something means. The syntax is "wtf [is] <acronym>". To a unixhead, the is isn't necessary, but it makes the command read like a sentence.
If I'm willing to add in those little words, I find the best lines of code will read like a sentence
if (foo.equals(bar)) { /* then */
...
or
mv file [to] newname
- michaelcampbell 15y agoI do that sometimes with java code. My support guys have given me some "thanks, your code is easy to read" type emails occasionally. Good naming helps, although some consider it overly verbose. To wit: public static final BigDecimal BY_100 = new BigDecimal("100.00"); ... BigDecimal amountInDollars = amountInCents.divide(BY_100); Sometimes I do it just for my own amusement, too.