Class properties and class var's - How do you use them?

Class properties and class var's - How do you use them?

There are times I am wondering if they really are just a reinvention of global variables.

Comments

  1. I have no use for class properties - if by that you mean properties with the "class" keyword before them - only functions :) Let alone class variables.

    ReplyDelete
  2. Class variables are like global variables but their scope is limited by the class. This help make things clearer and avoid name collision.

    ReplyDelete
  3. I usually only ever use them to create singleton patterns for my classes.

    ReplyDelete
  4. Singletons and registrations, as an alternative to variables in the implementation section.
    Though I'm not entirely decided, variables in the implementation section have the benefit of being completely hidden from the interface (as they should be), while class vars appear in the interface section.
    Class properties are mostly useful if you use static classes and virtual class functions (instanceless services)

    ReplyDelete
  5. Eric Grange And unfortunately code completion is broken and even lists class vars that are private.

    ReplyDelete

Post a Comment