NYCPHP Meetup

NYPHP.org

[nycphp-talk] Static variables, self:: and abstract classes

Andrew Kamm akamm at demicooper.com
Wed Jun 7 08:25:46 EDT 2006


>just one question had crossed my mind right now...
>
>why did u had declared the variable as static?

The idea was to have an abstract parent class for customer preferences since
most preference classes would basically share the same code.  The static
vars (or constants) that were to be stored in the individual classes were
properties that differentiate how the child classes would interact with the
database (among other things).

Some of the methods within the classes were not object-specific, but rather
class-specific operations (like a getList() method to get a an array of
options for a specific type of preference (class) rather than something
related to an actual object instance).

For example: customerPreference has child class 'beds' which can be
referenced statically for information about 'beds' in general or you could
instantiate a 'beds' object that refers to '2-bedroom' or '4-bedroom', etc.

Some of the vars I was attempting to store as static (or as constants) were
things like "tableName", "linkTableName", "isMult", etc.

thanks-

-- 
Andrew Kamm







More information about the talk mailing list