HNHacker News
TopNewBestAskShowJobs

peter_hilton

5 karma · joined March 16, 2015

Freelance software developer, writer, public speaker, and amateur musician. Product developer at Effektif.
submissionscomments
peter_hilton··on How to name things in programming
> "text_correction_by_editor" might convey a lot more info then "edit"

In the talk I explain that this is a real example, from software for a publishing company in the Netherlands. The 'editor' is the person who edits the text. The problem was that the subject matter experts used two different Dutch words for two different kinds of text correction, depending on whether the original author or the editor made the correction.

This example is about the tradeoff between making the difference explicit (text_correction_by_author vs text_correction_by_editor), or agreeing on consistent translations for the two Dutch words (e.g. 'edit' and 'revision').

peter_hilton··on How to name things in programming
> my worst habit it just trying to use words with the same number of characters for different variables so they align

Yes, you have worse problems than ambiguous abbreviations :) That doesn't make the abbreviations okay, though.

peter_hilton··on How to name things in programming
> the advice either has little value or doesn't really apply to programming

When I give this talk, I make this clear. I agree. The point is that there's a lot more good advice from writers over the fine details of prose than there is from coders about fine details of code, such as naming. In the talk, I conclude that the advice from writers is entertaining, but not really relevant, but that it can inspire us to try to come up with our own guidelines for naming.

> We have these rules in programming for how to write variable names

Not enough. Also, they tend to be badly written and lack humour. But please share your favourites.

> when writing a novel a writer should create living people; people not characters. A character is a caricature

This is a digression from coding to functional design, in which 'personas' can be a useful refinement of the concept of an anonymous 'user'.

peter_hilton··on How to name things in programming
> An important rule is missing here: variables should be named with their scope in mind

True, but I have plenty of slides in my presentation without adding more :)

The 'small scope rule' is more of a situation when you can get away with names that are less good, because of the small scope. When I get into discussions about that, everyone agrees with each other, and it distracts from the issue of coming up with good names when the scope isn't tiny.

Also, 'i' for a loop control variable is a trick example: why aren't you using a language that loops over collections without using a loop index?

peter_hilton··on How to name things in programming
What’s not on the slide, but which I say during the talk, is that I’m making an analogy here between ‘Don’t use passive voice’ (English) and ‘use noun phrases for class names’ (object-oriented programming). Both are kinds of grammatical guidelines.

What I also say in the talk is that this analogy is a stretch, but at least advice from writers about writing can inspire us to think about how we write code.