>
> Currently I do use controllers, big controllers with several of its own
> functions within the ProductlistAction() function, to do everything the
> "products list" pages do. That includes getting the products from the
> database...
>
Hi Rishi, this is exactly the type of information that can be retrieved via
a "Product" model. You would essentially retrieve a "list" of models that
fit the "criteria" selected.
Rishi Daryanani wrote:
>
> ...and generating each filter as a side menu on the page.
>
So, each item on the side-menu is a selection criteria/condition. These are
often referred to as search/filter facets.
Rishi Daryanani wrote:
>
> Each "filter" comes from its own two tables, e.g. colour has a "colour"
> table and a "colour_language" linked table for a description per language.
> "Length" has a "length" table with a "length_language" table for a
> description per language. (Multi lingual site).
>
In this case, it does sound like you could defer to building a "Facet"
model. This would really pull a TON of logic away from your controllers and
allow you some testability. Something I am sure you would be hard pressed to
achieve today (you can always re-factor a piece at a time to achieve better
testability).
Rishi Daryanani wrote:
>
> I have no problem in sorting it all out via controllers, as that is what
> we've been doing all along. I'm just trying to understand if there is a
> better way to separate code or classes
>
I would honestly recommend that you clean up your controllers by moving the
logic out to models. You'll find that this will significantly help your
maintenance efforts. The other stuff can be refactored later.
BTW, David made a good point about not necessarily moving to modules. To add
to that point, I would say that I can't tell you whether it is a good idea
or not because I really only know about one part of your application at this
point. To tell you one way or the other would be a guess at this point. I
_can_ tell you that it is probably the last thing you should be focusing on
at this point as it is mostly an organizational tool.
Rishi Daryanani wrote:
>
> ...if they needed to edit a site which uses controllers the way I
> described (without models), what would THEY do to improvise the code,
> let's say, as a quick start for the filters / situation I described in my
> previous mail?
>
As noted above, I would start by moving the logic out of the controller and
go for better testability.
-----
--
Wil Moore III
Why is Bottom-posting better than Top-posting:
http://www.caliburn.nl/topposting.html
--
View this message in context: http://zend-framework-community.634137.n4.nabble.com/How-to-instantiate-a-model-class-to-use-its-functions-standard-solution-tp3054833p3064293.html
Sent from the Zend MVC mailing list archive at Nabble.com.
没有评论:
发表评论