PHP5 practices

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

User avatar
Ambush Commander
DevNet Master
Posts: 3698
Joined: Mon Oct 25, 2004 9:29 pm
Location: New Jersey, US

Post by Ambush Commander »

I guess I have to say that I'm a bit opposite of you guys and most of my objects have public member variables; this is usually for optimization purposes (cut down on unnecessary member variable calls) and also because I don't build fields that need to have their contents validated on write (generally this gets delegated to another layer).

When I am in a PHP 5 mindset, the variables are generally protected unless it's a hacky solution, then I use private. My problem with making everything private to start with is that you often don't think up of ways to extend your class. I find that the most instructive times for adding plug points is when an end user needs extra functionality; I take a look at the class and I can usually instantly see where the flex point needs to be. Usually, it hasn't been made available to the user.
Post Reply