Re: Fat Models vs. App Controller

2011-02-27 Thread AD7six


On 27 feb, 00:02, Eric Anderson andersoneric...@gmail.com wrote:
 Hi everyone,

 Just wondering when it comes to performance and any other factors you
 may deem important, what's the better option for storing functions
 that I will use among many controllers: A function in the model that I
 can then access via $this-Model-Model-function() or a function
 inside of my App Controller?

controller and model functions shouldn't overlap in functionality. The
short answer if you're asking is: always in the model.


 Moreover, when is it better to put a function in a model and when is
 it better to put it in the app controller?

you put controller logic in controllers, and model logic in models. If
you were to put whatever it is you're thinking about in your app
controller and within it call a model it's most likely the wrong thing
to be doing (asside from the fact that putting things in your app
classes is generally a bad design - use components, behaviors and
helpers) unless the controller function is controlling in some way
e.g. a couple of lines of code to collecting params and call a model
method.


 To put this in context, I'm investigating this for use with an
 activities feature. I track activities and then display them in feeds.
 Of course, I need to quite often save an activity, feeding it
 arguments (as well as delete an activity).

Model.

  Moreover, I need to often
 grab a feed, customized based on the arguments I feed it.

Model.

  I'm trying
 to avoid using RequestAction.

Good - because requestAction, while not the performance killer it used
to be, is still an easy way to completely miss the point of MVC.

AD

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Fat Models vs. App Controller

2011-02-26 Thread euromark
usually you would put functions you use in multiple controllers in
either the model (data?) or a component (logic?)
you can also use libs to dry your code :)


On 27 Feb., 00:02, Eric Anderson andersoneric...@gmail.com wrote:
 Hi everyone,

 Just wondering when it comes to performance and any other factors you
 may deem important, what's the better option for storing functions
 that I will use among many controllers: A function in the model that I
 can then access via $this-Model-Model-function() or a function
 inside of my App Controller?

 Moreover, when is it better to put a function in a model and when is
 it better to put it in the app controller?

 To put this in context, I'm investigating this for use with an
 activities feature. I track activities and then display them in feeds.
 Of course, I need to quite often save an activity, feeding it
 arguments (as well as delete an activity). Moreover, I need to often
 grab a feed, customized based on the arguments I feed it. I'm trying
 to avoid using RequestAction.

 Thanks!

 Eric

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Fat Models vs. App Controller

2011-02-26 Thread Eric Anderson
Ya a component doesn't necessarily work because I'm interfacing with
the DB (inserting, deleting, querying) a lot. I'm thinking from
articles I've been digging up (Mark Story's personal site) that
putting these functions in my Activity controller makes the most
sense, then I can just grab feeds, save data, etc by calling the
function through related models.

As for libs, what do you mean? I can create a library for these
functions? Can you explain further?

Thanks!

Eric

On Feb 26, 4:39 pm, euromark dereurom...@googlemail.com wrote:
 usually you would put functions you use in multiple controllers in
 either the model (data?) or a component (logic?)
 you can also use libs to dry your code :)

 On 27 Feb., 00:02, Eric Anderson andersoneric...@gmail.com wrote:







  Hi everyone,

  Just wondering when it comes to performance and any other factors you
  may deem important, what's the better option for storing functions
  that I will use among many controllers: A function in the model that I
  can then access via $this-Model-Model-function() or a function
  inside of my App Controller?

  Moreover, when is it better to put a function in a model and when is
  it better to put it in the app controller?

  To put this in context, I'm investigating this for use with an
  activities feature. I track activities and then display them in feeds.
  Of course, I need to quite often save an activity, feeding it
  arguments (as well as delete an activity). Moreover, I need to often
  grab a feed, customized based on the arguments I feed it. I'm trying
  to avoid using RequestAction.

  Thanks!

  Eric

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Fat Models vs. App Controller

2011-02-26 Thread Sam Sherlock
to me it sounds list behaviours

all controllers extend the app controller - choose carefully what you put
here

if the stuff is entity related it goes in model

you can add to app model ( helper  error also) in the same way as you can
with app controller

fat models, skinny controllers and athletic behaviours
http://nuts-and-bolts-of-cakephp.com/tag/observable-behavior/
 - S




On 26 February 2011 23:46, Eric Anderson andersoneric...@gmail.com wrote:

 Ya a component doesn't necessarily work because I'm interfacing with
 the DB (inserting, deleting, querying) a lot. I'm thinking from
 articles I've been digging up (Mark Story's personal site) that
 putting these functions in my Activity controller makes the most
 sense, then I can just grab feeds, save data, etc by calling the
 function through related models.

 As for libs, what do you mean? I can create a library for these
 functions? Can you explain further?

 Thanks!

 Eric

 On Feb 26, 4:39 pm, euromark dereurom...@googlemail.com wrote:
  usually you would put functions you use in multiple controllers in
  either the model (data?) or a component (logic?)
  you can also use libs to dry your code :)
 
  On 27 Feb., 00:02, Eric Anderson andersoneric...@gmail.com wrote:
 
 
 
 
 
 
 
   Hi everyone,
 
   Just wondering when it comes to performance and any other factors you
   may deem important, what's the better option for storing functions
   that I will use among many controllers: A function in the model that I
   can then access via $this-Model-Model-function() or a function
   inside of my App Controller?
 
   Moreover, when is it better to put a function in a model and when is
   it better to put it in the app controller?
 
   To put this in context, I'm investigating this for use with an
   activities feature. I track activities and then display them in feeds.
   Of course, I need to quite often save an activity, feeding it
   arguments (as well as delete an activity). Moreover, I need to often
   grab a feed, customized based on the arguments I feed it. I'm trying
   to avoid using RequestAction.
 
   Thanks!
 
   Eric

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group
 at http://groups.google.com/group/cake-php


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Fat Models vs. App Controller

2011-02-26 Thread Eric Anderson
Awesome article. Thanks!

I think I'm going to move everything over to my model, via either an
available function I can then call from other controllers or place the
function in beforeSave, afterSave, etc. Should work great.

Eric

On Feb 26, 5:59 pm, Sam Sherlock sam.sherl...@gmail.com wrote:
 to me it sounds list behaviours

 all controllers extend the app controller - choose carefully what you put
 here

 if the stuff is entity related it goes in model

 you can add to app model ( helper  error also) in the same way as you can
 with app controller

 fat models, skinny controllers and athletic 
 behaviourshttp://nuts-and-bolts-of-cakephp.com/tag/observable-behavior/
  - S

 On 26 February 2011 23:46, Eric Anderson andersoneric...@gmail.com wrote:







  Ya a component doesn't necessarily work because I'm interfacing with
  the DB (inserting, deleting, querying) a lot. I'm thinking from
  articles I've been digging up (Mark Story's personal site) that
  putting these functions in my Activity controller makes the most
  sense, then I can just grab feeds, save data, etc by calling the
  function through related models.

  As for libs, what do you mean? I can create a library for these
  functions? Can you explain further?

  Thanks!

  Eric

  On Feb 26, 4:39 pm, euromark dereurom...@googlemail.com wrote:
   usually you would put functions you use in multiple controllers in
   either the model (data?) or a component (logic?)
   you can also use libs to dry your code :)

   On 27 Feb., 00:02, Eric Anderson andersoneric...@gmail.com wrote:

Hi everyone,

Just wondering when it comes to performance and any other factors you
may deem important, what's the better option for storing functions
that I will use among many controllers: A function in the model that I
can then access via $this-Model-Model-function() or a function
inside of my App Controller?

Moreover, when is it better to put a function in a model and when is
it better to put it in the app controller?

To put this in context, I'm investigating this for use with an
activities feature. I track activities and then display them in feeds.
Of course, I need to quite often save an activity, feeding it
arguments (as well as delete an activity). Moreover, I need to often
grab a feed, customized based on the arguments I feed it. I'm trying
to avoid using RequestAction.

Thanks!

Eric

  --
  Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
  Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
  others with their CakePHP related questions.

  To unsubscribe from this group, send email to
  cake-php+unsubscr...@googlegroups.com For more options, visit this group
  athttp://groups.google.com/group/cake-php

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php


Re: Fat Models vs. App Controller

2011-02-26 Thread Sam Sherlock
I have just finished moving some a controller method to a model just now (if
the same logic had to be used by multiple models then I would have made a
helper)

my app manges a list of jobs held in a db (an external system puts them in -
another reason why behaviours would not work in my case; my system just
monitors what the system logs)

so I had a controller method checking the params of a job for validity  if
files exist and stuff; is such a record first in set
having the model check validty meant less code overall and great ablity to
reuse it

so now my index view of jobs shows faily detailed overiew of the job params
- with error feedback for user

I baked this app in about 8 minutes and tweaked afterwards- very rapid
development; near complete

 - S




On 27 February 2011 01:30, Eric Anderson andersoneric...@gmail.com wrote:

 Awesome article. Thanks!

 I think I'm going to move everything over to my model, via either an
 available function I can then call from other controllers or place the
 function in beforeSave, afterSave, etc. Should work great.

 Eric

 On Feb 26, 5:59 pm, Sam Sherlock sam.sherl...@gmail.com wrote:
  to me it sounds list behaviours
 
  all controllers extend the app controller - choose carefully what you put
  here
 
  if the stuff is entity related it goes in model
 
  you can add to app model ( helper  error also) in the same way as you
 can
  with app controller
 
  fat models, skinny controllers and athletic behaviourshttp://
 nuts-and-bolts-of-cakephp.com/tag/observable-behavior/
   - S
 
  On 26 February 2011 23:46, Eric Anderson andersoneric...@gmail.com
 wrote:
 
 
 
 
 
 
 
   Ya a component doesn't necessarily work because I'm interfacing with
   the DB (inserting, deleting, querying) a lot. I'm thinking from
   articles I've been digging up (Mark Story's personal site) that
   putting these functions in my Activity controller makes the most
   sense, then I can just grab feeds, save data, etc by calling the
   function through related models.
 
   As for libs, what do you mean? I can create a library for these
   functions? Can you explain further?
 
   Thanks!
 
   Eric
 
   On Feb 26, 4:39 pm, euromark dereurom...@googlemail.com wrote:
usually you would put functions you use in multiple controllers in
either the model (data?) or a component (logic?)
you can also use libs to dry your code :)
 
On 27 Feb., 00:02, Eric Anderson andersoneric...@gmail.com wrote:
 
 Hi everyone,
 
 Just wondering when it comes to performance and any other factors
 you
 may deem important, what's the better option for storing functions
 that I will use among many controllers: A function in the model
 that I
 can then access via $this-Model-Model-function() or a function
 inside of my App Controller?
 
 Moreover, when is it better to put a function in a model and when
 is
 it better to put it in the app controller?
 
 To put this in context, I'm investigating this for use with an
 activities feature. I track activities and then display them in
 feeds.
 Of course, I need to quite often save an activity, feeding it
 arguments (as well as delete an activity). Moreover, I need to
 often
 grab a feed, customized based on the arguments I feed it. I'm
 trying
 to avoid using RequestAction.
 
 Thanks!
 
 Eric
 
   --
   Our newest site for the community: CakePHP Video Tutorials
  http://tv.cakephp.org
   Check out the new CakePHP Questions sitehttp://ask.cakephp.organd help
   others with their CakePHP related questions.
 
   To unsubscribe from this group, send email to
   cake-php+unsubscr...@googlegroups.com For more options, visit this
 group
   athttp://groups.google.com/group/cake-php

 --
 Our newest site for the community: CakePHP Video Tutorials
 http://tv.cakephp.org
 Check out the new CakePHP Questions site http://ask.cakephp.org and help
 others with their CakePHP related questions.


 To unsubscribe from this group, send email to
 cake-php+unsubscr...@googlegroups.com For more options, visit this group
 at http://groups.google.com/group/cake-php


-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php