1

I use an MVC web framework to create an application which contains a hierarchy:

Location <1-N> Devices <N-M> Services

I have a number of Locations. Each Locations can have several devices (represented by an 1-N relationship in the database). Each device runs services. The services (like http, ftp, etc) are defines in an extra table and are connected to the devices using an N-M relationship.

So far I have a model for each of the entities and one Location-controller for CRUD operations. Since the devices somehow belong to the location all the device CRUD-functions are located in the location controller as well. The services have their own controller. The url to access the data is structured like this:

/locations/    # to get an overview of the locations
/locations/*id*/    # to view the details of one location
/locations/*id*/edit    # to edit the details of one location
/locations/*id*/device/*deviceid*/    # to view details of a device
/locations/*id*/device/*deviceid*/edit    # to view details of a device
/services/     # list of all the services
/services/*id/    # view details of a service

Note: There are also urls to create and delete entries, which are omitted. But I think you get the idea.

Now to my questions: It feels wrong, and I think it is wrong to put all the functions inside the Location-controller, therefore I would like to move them so separate controllers. On the other hand, I like the URL-Structure, since it represents the hierarchy of the data pretty well. Furthermore I like when the URL structure corresponds with the Controllers.

What is the "better" solution: Separate controllers with combined URLs? Separate controllers, separate URLs? Or combined controller with combined URLs?

  • How do you track the history of installations of an individual device over time? Does the location have an affect on which services a device has or provides? – JeffO Apr 23 '14 at 10:12
  • Devices have a fix location and cannot be moved between locations. The location has no influence on what services are running on the devices or on the services them self. – Peanut Apr 23 '14 at 11:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.