1

I have a question about designing MVC app architecture.

Let's say our application has three main categories of views (items of type 1, items of type 2...). And we have three (or more in future) types of users - Admins, let's say Moderators and typical Users. And in the future there might be more of them. Admins have full access to app, Moderators can visit only 2/3 type of items, and Users can visit only basic type of items.

Should I divide my controllers/views/whatever like this:

Items "A", Items "B", Items "C", then make them 100% finished and at the end add access privileges?

Pros:

  • DRY option

Cons

  • Conditional expressions in views

Or another options: Items "A" / Admin, Items "A" / Moderator / Items "B" Admin ...?

Pros:

  • Divided parts of application for specific user (is that pros?)

Cons:

  • A lot of repeated code

I don't have great experience in planning such things so it would nice if you can give me some tips or links to learn something about it.

1

MVP tells :

The model is an interface defining the data to be displayed or otherwise acted upon in the user interface.

User privilege level is just a parameter - as any other parameter. That means that your models should dictate what is allowed depending on that parameter. There are no needs to do additional complication (divide application as you suggested).

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.