News for hackers. Stuff that matters.
Re:Slow Down to Go Faster by mgkimsal on Wednesday September 29, 2010 @11:08AM (#1739654)
re: naming things.

Please have objects be nouns and methods be verbs. Please done have a class named "buildLetter" or "generateEmail" - it's confusing to read.

At least to me.

Perhaps I'm alone in that? I run in to enough "objects named as verbs" I'm sort of beginning to wonder if I'm alone in this thinking.

Re:Slow Down to Go Faster by Xurinos on Wednesday September 29, 2010 @11:23AM (#1739716)
Only thing I am on the fence about is "methods be verbs", unless your language differentiates between methods and properties. The exception in my mind was the classic Point.x, where x is a method for accessing the value of an internal x.

Note that some languages, such as perl, understand whether you are setting or getting by the surrounding syntax:

   my $x = $point->x;   # get the value of x
   $point->x(100);      # set the value of x
Re:Slow Down to Go Faster by po on Wednesday September 29, 2010 @11:37AM (#1739787)
"point" can be a verb too. :-)

Just today I renamed a method someone named "showButton" because I thought

  result = showButton()
was a call that showed the button and returned a boolean result. In reality it just returned a boolean based on if it was configured to show a button. The new name: "shouldShowButton"

But then I got to thinking… well… maybe I'm suggesting that the button should be shown…

There's something to be said for context.

Re:Slow Down to Go Faster by smcl on Wednesday September 29, 2010 @02:40PM (#1740568)
I usually write out a bunch of names without thinking to hard about them and then try to read them. In this instance, given that you've already had showButton and shouldShowButton i'd probably look at:

  result = buttonShown()
  result = buttonVisible()
  result = buttonIsVisible()
  result = visibleButton()
  result = !buttonHidden()
To a lot of programmers this would seem like a waste of time, but I'm with the article's author (and, I'd hope, other HN readers) in that it's time well spent.
Re:Slow Down to Go Faster by eljaco on Wednesday September 29, 2010 @02:08PM (#1740415)
[Redacted] Misread your post.
Re:Slow Down to Go Faster by atomical on Wednesday September 29, 2010 @11:52AM (#1739846)
What would confuse me about generateEmail is that on the surface without even looking at the code I would wonder if it built the e-mail body itself or sent out an e-mail or both.