Hacker News new | ask | show | jobs
by bennyg 4570 days ago
Good naming conventions are pretty key here. My guess is the original writer of that code had used those in something else entirely, then reused those methods in a new method so he wouldn't have to rewrite.

I always feel like it's better to positively name Boolean values, personally, but I know everyone is different.

1 comments

What he hand-waves is that he's got something that looks like this:

  def signed_out?
    # Code
  end
  
  def signed_in?
    !signed_out?
  end
Which can easily start to become its own problem. On the other hand, with Ruby, it might be worthwhile to define something like Class#invert such that you have this:

  def signed_out?
    # Code
  end
  method_invert :signed_out?, :signed_in?
Dunno. I haven't ever found myself in a position where it mattered.