Posted: Thu Jul 05, 2007 6:19 pm
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.
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.