Welcome Guest, Not a member yet? Register   Sign In
At what point do you seperate things into different models?
#1

(This post was last modified: 06-20-2016, 04:46 AM by CINewb.)

Let's say you have a model called "Range"

A Range model might consist of a name, a description, and an image.

Then let's say you have a model called "Product".  You could have several Products to a Range.  A Product model would consist of a size, a colour and a price.

OK, so the above is fine.  However, I find that in places I am doing MySQL joins on the Product and Range tables.  For example, I might want to display a table of all Ranges along with their associated size, colour and price values from the Product table.  This really starts to blur the lines between the separate models.  Which model should be responsible for generating such information, the Range or the Product?

It's got me thinking, should Range and Product all be part of the same model?  The problem with that approach is that you might have a "Customer" and an "Order" model to represent customers and purchases.  Customers are related to Orders, and Orders are related to Products, and Products are related to Ranges.  At some point there are going to be requirements to join some or all of this information together in different controllers and views. You could therefore end up with one giant model which encompasses everything, which would not be good either.

Thoughts?
Reply


Messages In This Thread
At what point do you seperate things into different models? - by CINewb - 06-20-2016, 04:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB