Welcome Guest, Not a member yet? Register   Sign In
HMVC the right way ?!
#36

(06-03-2015, 12:40 AM)RogerMore Wrote: Ok, so it's better to load the news model and news library from my page controller. 
Then model retrieves the data and I give it to the library to process it into data for a view?

In most cases this is true. You generally want each class to be as simple as possible, especially since this often makes them more reusable.

For a simplified example, I could build a library which calls my model to retrieve some data, then creates a select element (drop-down), using one column for the values and another for the content/displayed value. However, this would tie the library to the model (and possibly even to the columns), and the library would know far more about the data than is really necessary for this functionality.

If I instead built my library to expect the data and column names to be supplied as needed, the library could be used to transform any dataset into a select element. If the library contains a series of methods for performing transformations on data, you may decide that the data to be transformed should be passed to the constructor, while any additional information required for the transforms (like the column names for the drop-down) could be passed to the methods.

Of course, this example is simple enough that much of the required functionality is built into many base models, but I hope it helps to illustrate the point.
Reply


Messages In This Thread
HMVC the right way ?! - by RogerMore - 05-26-2015, 02:10 AM
RE: HMVC the right way ?! - by gadelat - 05-26-2015, 03:15 AM
RE: HMVC the right way ?! - by kilishan - 05-26-2015, 07:08 AM
RE: HMVC the right way ?! - by Narf - 05-26-2015, 01:16 PM
RE: HMVC the right way ?! - by kilishan - 05-26-2015, 10:32 PM
RE: HMVC the right way ?! - by mwhitney - 05-27-2015, 08:24 AM
RE: HMVC the right way ?! - by frocco - 05-27-2015, 12:18 PM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 06:49 AM
RE: HMVC the right way ?! - by kilishan - 05-27-2015, 10:14 PM
RE: HMVC the right way ?! - by kilishan - 05-27-2015, 10:29 PM
RE: HMVC the right way ?! - by frocco - 05-28-2015, 05:47 AM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 07:06 AM
RE: HMVC the right way ?! - by RogerMore - 05-28-2015, 12:06 PM
RE: HMVC the right way ?! - by josetrindade - 06-02-2015, 10:30 AM
RE: HMVC the right way ?! - by RogerMore - 05-29-2015, 07:24 AM
RE: HMVC the right way ?! - by kilishan - 05-29-2015, 07:30 AM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 08:05 AM
RE: HMVC the right way ?! - by Narf - 05-29-2015, 09:50 AM
RE: HMVC the right way ?! - by mwhitney - 05-29-2015, 12:09 PM
RE: HMVC the right way ?! - by Narf - 05-30-2015, 05:47 AM
RE: HMVC the right way ?! - by mwhitney - 06-01-2015, 08:13 AM
RE: HMVC the right way ?! - by Narf - 06-01-2015, 10:21 AM
RE: HMVC the right way ?! - by no1youknowz - 06-01-2015, 08:33 PM
RE: HMVC the right way ?! - by RogerMore - 05-29-2015, 08:16 AM
RE: HMVC the right way ?! - by RogerMore - 05-31-2015, 01:48 PM
RE: HMVC the right way ?! - by frocco - 06-01-2015, 05:26 AM
RE: HMVC the right way ?! - by kilishan - 05-31-2015, 10:05 PM
RE: HMVC the right way ?! - by RogerMore - 06-01-2015, 10:49 AM
RE: HMVC the right way ?! - by mwhitney - 06-02-2015, 12:06 PM
RE: HMVC the right way ?! - by frocco - 06-01-2015, 12:02 PM
RE: HMVC the right way ?! - by RogerMore - 06-01-2015, 03:12 PM
RE: HMVC the right way ?! - by frocco - 06-03-2015, 03:41 AM
RE: HMVC the right way ?! - by RogerMore - 06-01-2015, 10:25 PM
RE: HMVC the right way ?! - by no1youknowz - 06-02-2015, 09:09 AM
RE: HMVC the right way ?! - by RogerMore - 06-03-2015, 12:40 AM
RE: HMVC the right way ?! - by mwhitney - 06-03-2015, 06:28 AM



Theme © iAndrew 2016 - Forum software by © MyBB