Cake 1.x does have this wrong although not intentionally, but there is
enough flexibility to deal with it. As others noted, it's fundamental
to OO design that rather than having functions that are passed data to
operate on, the data contains the behaviour and operates upon itself.
Message passing languages such as Smalltalk make this particularly
clear, but in cake the data are not objects.

What I initially wanted as soon as I started with cake was model data
not to be raw fields, but where appropriate to be comprised of object
instances so that those instances can then be asked to perform
operations. As an example, if a table row contains fields that model
two address instances, having called find I wanted to see the data
with two Address class instances rather than the underlying fields.
Similarly when storing a model, the data saved would contain object
instances rather than raw fields. What I didn't do was have the entire
row being a model instance, but I've realised that it needs to be too
in some if not all cases.

To implement this, and one of the reasons that cake is great is that
it was trivial to do, was to create a behaviour that implemented
before/after methods, and I specified a model member variable as an
array that listed the classes that a database row was comprised of,
and that optionally would name the instance (so for address this might
be "home", "work", "holiday" etc.). The name corresponded to a column
prefix in the schema. The model then just acts as this new behaviour
and all find and save operations can work with class instances where
appropriate instead of raw columns. A little performance overhead but
nice to be in the world of objects again rather than data fragments.
The bigger win will be when the entire row is a class instance and
that's coming next.

I'll post the behaviour in due course in case it's useful to anyone
else.

Despite the shortcomings, thumbs up to cake for having the flexibility
to extend easily. I've found myself almost over enthusiastically
extolling the virtues of Cake to two people recently because even when
there's one step backwards, there's then two steps forward and it
gives the feelgood factor again.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to