View Single Post
Old 09-30-2007, 12:52 PM   #2 (permalink)
Karl
The Reckoner
Advanced Programmer Top Contributor 
 
Karl's Avatar
 
Join Date: Sep 2007
Posts: 437
Thanks: 22
Karl is on a distinguished road
Default

Have you considered using "static classes"? These are great when you know that you do not need to create instances of a class, for example, a Session class.

In OOP however, I tend not to create too many globally declared functions/variables, so I personally don't run into this problem. For example, each "page" can be expressed as a Class. Seeing as each page is a "page", we can wrap all our page related data inside this class, we can then give access to common objects (as properties) inside the Page class.

So let's say I added myFunction() to my LoginPage class, I can simply access common objects though the page's properites, such as $this->m_pMyObject->doSomething();

It's a different pattern to development, and I guess you really can't switch over this late into it? I would seriously suggest the use of static classes over global variables, infact, you should aim to cut down on the number of globally defined variables and functions in your script, this is one of the places where OOP should shine.
Karl is offline  
Reply With Quote