First of all, i must admit that this discussion is becoming very
interesting, because i often find myself thinking if the way i'm
doing something with CakePHP is actually the right way.

My suggestion in using the after_find was just an example of
a restricted case, but I think that it's not the true correct way
to do things (because there could be a lot of situations in which
we cannot apply that, and there are also many cases in which
that solution is not efficient at all).

I think that the fact that the Model Classes are often used as
nothing more than an associative array, so sometimes i don't
consider those real classes; that's why i prefer to let access them
only from the controller.
And i even think that making some shortcut from the view to the
model, could create some problems with the routing/security/etc.
because in that way there are actually ACTIONS not controlled (nor
performed) by a CONTROLLER. For example if you then want to
make any statistic on those performed actions where can you put
 your code then? in the model? in the view? ..there is not the
controller.

Bye,
   Andrea

On Oct 5, 9:49 am, skylar <[EMAIL PROTECTED]> wrote:
> I'm really curious about this topic as well as it speaks to an aspect
> 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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to