[thelist] PHP object property getters/setters

Andrew Kamm akamm at demicooper.com
Wed Nov 30 16:56:39 CST 2005


Thanks Paul - Here's a hypothetical example of what I meant by objects
within objects, etc .  Not sure if this is how it was taken:

Say I have 3 classes - city, state, customer. A customer object would have a
city object as one of it's properties (where the customer lives). The city
object would have a state as one of it's properties (the state where the
city is located). So using public properties, I could access info about a
customer's state by climbing up the chain:

$customer->city->state->stateName

Does that make sense or is that bad form?

Thanks!




On 11/30/05 2:11 PM, "Paul Bennett" <Paul.Bennett at wcc.govt.nz> wrote:

> Hi Andrew,
> 
> At a cursory glance, (and I'm open to flaming on this one, having had a small
> amount of OOP experience in PHP) if you really started storing 'objects within
> objects within objects' then I'd have a good look at your application logic
> and see if you just can't make things simpler.
> 
> Often the simplest solution is the best, and I usually find with complex
> problems that the KISS principle applies universally.
> 
> Paul


 





More information about the thelist mailing list