of the CakePHP Model class that has never really clicked with me.
Andrea's example is perfect for explaining the point.
In most MVC frameworks, when you retrieve data from storage (ram, db,
file, etc), you usually get an instance of the model class itself, not
a map/dictionary structure. This makes it easy to fetch calculated
values, such as full_name, age, etc. In one respect, you could
consider these "helper" functions, but I usually think of them as
smart accessors - you store the minimal data necessary and calculate
more common derived values on the fly (or you cache them in the rare
chance it's worthwhile to do so).
Andrea's suggestion (pre-calculating values in the after_find method)
makes sense, but it assumes that the value is always worth calculating
and storing after a lookup. (Perhaps you don't always need the value,
or calculating it takes a long time). So what's the recommended
convention for CakePHP for handling this stuff? Better yet, what do
some of you who are veterans with the framework do?
I could imagine it could be a helper class available to views where
the input is the map of values. I could imagine something like QRCC
suggests where its a method (static?) on the Model. Still, none of
this feels right. I'm looking for something elegant and hope someone
out there has already worked through this as a design issue.
Thanks,
skylar
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment