NYCPHP Meetup

NYPHP.org

Position of variable definitions [was: Re: [nycphp-talk] php script]

Mitch Pirtle mitch.pirtle at gmail.com
Tue Feb 26 15:01:45 EST 2008


Another consideration is in what kind of environment(s) your code will
be running, and who will be working on it. I've seen MVC-centric
frameworks take the approach of putting a method at the top of every
model that basically sets the variables that might be used by that
model, and then call them from a getVariable() or some such method
later to ensure the context is consistent. As well, this has been used
as a (kludge-like, IMHO) solution for creating codebases that need to
support PHP4 and PHP5; and basically provides a model-based namespace
and avoids the "whups, no constructors in this PHP version" problem.

The only thing I like about the concept is that you know where all
your public variables are, and it forces you to think long enough
about your variables to have an edumucated opinion on how you
implement your model.

-- Mitch



More information about the talk mailing list