When people use abbreviations, stuff is confusing:

When people use abbreviations, stuff is confusing:

function StripBra( AStr: string ): string;

Comments

  1. So which kind(s) of bra does it strip?
    Answer will be later today.

    ReplyDelete
  2. I wonder if it should return a bra instead of a string :D

    ReplyDelete
  3. Maybe it should return a thread instead of a string?

    ReplyDelete
  4. I'm not linking any pictures, but getStringFromObject() from Java comes to my mind.

    ReplyDelete
  5. It's for Bra–ket notation of course. :-)

    ReplyDelete
  6. Uli Gerhardt So it strips only the left side?

    ReplyDelete
  7. Uwe Raabe We'd need to see more to be sure. :-)

    ReplyDelete
  8. Clearly it strips the bra from a bra-ket pair. So pass it '' and it'll return the ket '|b>'. I mean, what else could it possibly do?

    ReplyDelete
  9. At least it wasn't
    function StripBra( gString:string ):string;

    ReplyDelete
  10. Agreed, for instance, I've never been able to remember the 'Contnrs' unit file in which TObjectList resides :P

    ReplyDelete
  11. Shouldn't return anything since its a verb. Function names should be nouns.

    ReplyDelete
  12. David Heffernan Curious -- I've never heard anyone say this. I'd argue that functions should be verbs. Why should they be nouns?

    ReplyDelete
  13. Not being well at natural languages: Isn't "Stripped" just a specific tense of a verb?

    ReplyDelete
  14. Getters and setters are special, you read the Get prefix, know it's a getter, know that it should not modify any state, and what comes after the Get is the name of the property, which is a noun.

    I'm working under the assumption that, by and large, a function should not change state, should be idempotent. It's good to aim for that but it's not always possible.

    Consider a method of a string that trimms whitespace, does not modify the subject, and returns a new value. Should it be:

    str.Trim();

    or

    str.Trimmed();

    Personally I prefer the latter.

    Jeroen Wiert Pluimers is quite right, this is not a noun/verb distinction. Clearly my grasp of grammar, even in my mother tongue, is weak. Scratch what I said about nouns.

    ReplyDelete
  15. I wonder if my favorite now is
    function Topless( aStr:string):String;

    ReplyDelete
  16. I find the tenor of many of these comments unfit for this community. All non technical comments here are not appropriate.

    ReplyDelete
  17. David Heffernan You are killing all the fun :)

    ReplyDelete
  18. One of the most underrated and yet very important tasks at the start of a project - is to establish a dictionary of the vocabulary for the problem domain. Firstly to secure a common understanding of what things are, and secondly to create a base for good naming conventions based on something like Cwalina's guidelines.

    ReplyDelete
  19. David Heffernan But your Trimmed() is a method, not a free function. Would you still call it Trimmed() if it was a free function?

    ReplyDelete
  20. I think I would. Otherwise it seems like it would mutate the subject.

    ReplyDelete
  21. David Heffernan I agree for methods, but not for free functions. But I can't give you a good reason, just the way I feel. I guess for free functions I think in terms of math where parameter is not mutated.

    ReplyDelete
  22. Asbjørn Heid  I would always write Sum and Product rather than Add and Multiply, but there you go

    ReplyDelete
  23. David Heffernan You must be a lot of fun at parties

    ReplyDelete
  24. Or perhaps my idea of fun differs from yours

    ReplyDelete
  25. David Heffernan I'm pretty sure there's an ISO standard for what constitutes as fun.

    ReplyDelete
  26. The definition of fun is primarily opinion-based ...

    ReplyDelete

Post a Comment