Michel Fortin wrote:
On 2010-01-29 10:40:23 -0500, Andrei Alexandrescu <seewebsiteforem...@erdani.org> said:

I'll tell you what I'd have liked: a landslide of responses to my question revealing my mistaken ways and clarifying without a shade of a doubt that byLine should be a @property. Or not. (I don't even care which.)

The fact we're having a debate about this (and Steve even says it's a clear cut case and there are other more ambiguous!) is worrisome. Take this: I got different answers from _supporters_ of @property!

The problem entirely reside on the ambiguous semantics of 'byLine'. The name makes us think it does something while it does something else (consuming a line). If it did what we'd expect it should be a property, but since it does not it shouldn't be. Fix 'byLine', either by changing the name or changing what it does, and whether it's a property or not will become clear.

This is a very good point! Using byLine as an argument against @property is just silly, as it is badly-named to begin with. The name itself doesn't really tell you what it does, you have to read the docs or see it in the context of a foreach to understand it. The omittable parentheses are not the problem here. A more descriptive name would be either of these, depending on how the function actually works:

  readByLine()   // not a property
  lines          // definitely a property
  byLinesRange   // also definitely a property


A good convention is one that you apply without wasting time to think of it every single time you use it: naming conventions, braces conventions, even most class vs. struct conventions. The well-defined ones work great because _they save you time_.

Well, you should probably care a little more about your naming convention. It's confusing, and it'll probably end up waisting the time of some people who'll wonder why it consumes lines before you read them. I was absolutely sure it didn't before someone pointed it out to me.

Speaking of Andrei's naming convention; in the case of empty() there were a lot of protests to the name, because people couldn't tell whether it was a property or an action. The @property annotation mends that.

-Lars

Reply via email to