|
OO PHP code and $_SESSION
Alright, so here is a quick question to think about... when designing code in PHP to be used for web-content generation and web-applications when attempting to design the code using an object oriented approach do you allow classes the need to store data in the $_SESSION access the superglobal directly, or do you pass access in through the parameters (or constructor) manually?
In theory allowing direct access to the superglobal does kind of violate the OO approach to coding since the $_SESSION variable could contain an unknown set of variables and you could be corrupting another classes code.. it allows removes the flexibility of one day using your class without $_SESSION.
While passing everything by reference tends to maintain the oo paradigm and allows for maximum flexibility.
|