tags:

views:

51

answers:

1

I'm playing with the ASP.NET MVC Framework, trying to create a simple site.

My model is essentially: -Questions -Answers -Categories

Since each Question must belong to a Category and each Answer must belong to a question - is it correct to split 'Category' into it's own controller?

What would be incorrect about creating a controller path of /Question/Category/List?

Also, if I wanted to create a search - do I then create a controller called 'Search' and use like so: /Search/Question/, /Search/Answer/? Or do I use '/Question/Search/'?

Thank you in advance for any insight.

+1  A: 

Below is a read regarding grouping controllers Grouping Conrollers

The above is not directly related to your question but may be useful.

Now regarding your question, I'll take it this way.. (This is just one way)..

My initial take on this...

-for Questions and Category

  • /Question/Ask
  • /Question/Edit/{id}
  • /Question/List
  • /Question/Search/{criteria}

  • /Category/Create

  • /Category/Edit/{id}
  • /Category/List

-for answer

  • /Question/Answer/{questionid}
  • /Question/Answer/Search/
  • /Question/Answer/List/Group/Question

The other approach is to separate the controller with respect to Admin and Visitor functionality. Put all the admin logic like create/update/ in one controller and split the remaining logic into other controllers. There may be +/- argument to this. But's that's an individuated opinion.

Note:

  1. Category can exist independent of the question
  2. A question is associated with one or more category
  3. An answer belongs to a question and cannot exist independently.

*** The example came out of top of my head and may not be the best practice but may just give some points to ponder. :). Feel free to apply your ideas.

rajesh pillai