To use associative arrays violates the principles of OOP?

At some point, you will always need to know what your properties are called. You can make a data model (as you are doing, Fornitore class) but in this class you will still need to have properties like Fornitore->name, Fornitore->kind etc. So, if you want to call this from you controller you might say Fornitore->setName() in stead of saying $options['name'] = 'x'; but still, if you change Fornitore->name to Fornitore->Product_name, this will impact your Controller. Maybe a little bit less because when you change the property Fornitore->name, the method Fornitore->setName could still be called the same.

So, your controllers and models will have to know about each other somehow. It may be through an array or an object or whatever. In the end there will be some things you can't change without changing the other. And that's okay.

It's much better to use an array of options (as you did) then the "old" way of calling a function like add_furniture($name, $kind, $....) because that is really hard to change!

Messages In This Thread
To use associative arrays violates the principles of OOP? - by El Forum - 04-26-2010, 10:54 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.