Question

I am supposed to design a Q&A site similar to stack over flow and following are the features that I would like in my system,

Users   
    -Non-member
        -Sign-up
        -View questions and answers
        -Search for questions
    -Member (inherits above above features (except for sign-up) and the ones below)
        -Login
        -View question
        -Ask question
        -Answer question
        -Edit own question
        -Edit other user's questions (needs reputation)
        -Delete question
        -Vote on question (needs reputation)
        -Report other user's questions (needs reputation)
        -Comment on questions and answers
    -Moderator (upgraded from member inherits all the above features and the ones below)
        -Remove other questions
        -Create tags
        -Remove member (needs 4 other moderators' approval)

But I am confused with separating these to Models, Views and Controllers.

I tried to do using this template http://creately.com/diagram/example/gg3qz3ut/MVC but the Model and the Controller looks the same. I would be really grateful any of you experts give some ideas/ examples on how to separate these into the MVC model as this is the first time i am using this architecture.

Thank you :)

Was it helpful?

Solution

From your specifications above, I understand just User model behaviours depending on different roles.Let me explain what MVC is first, then i will introduce you a solution.In every data dependent system there is a storage which can be a database or an xml file.So in your code there should be objects represting those datas stored.For this case User and Moderator which inherits from user,(by the way I strongly suggest that use interfaces instead of inheritance,with interfaces your roles can be extended easily),Question,Comment .To get interaction with database and creates models for you to use in controller classes, you need also a Data Access Object layer, for this case UserDAO,QuestionDAO, CommentDAO which are implements a DAO interface. Let me move on to Controllers, Controllers are the classes which interacts with models and views, it simply makes little operations on Models and gives them to views, or gets data from views and manipluates it and gives to related DAO to store.For this case you need a SingupController,LoginController,QuestionController. For example, you take data from view of a signup form then you make a validation in SingupController.singUp() method, if its valid then you Call UserDAO to create a User row. I couldn't cover all of the specifications but i simply suggested a basic design.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top