2013-11-10 58 views
0

我應該設計問答&類似堆放超過流通A位和下面是我想在我的系統功能,MVC UML類圖設計

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) 

但我很困惑與分離這些到ModelsViewsControllers

我試過用這個模板http://creately.com/diagram/example/gg3qz3ut/MVC,但ModelController看起來一樣。我會非常感謝你們的專家給出了一些關於如何將這些分離成MVC模型的想法/例子,因爲這是我第一次使用這種體系結構。

謝謝:)

回答

1

從上面您的要求,我明白這取決於不同的roles.Let我解釋一下MVC是第一個只是用戶模型的行爲,那麼我將向你介紹一個solution.In每個數據相關的系統存在是一個可以是數據庫或xml文件的存儲。所以在你的代碼中應該有對象存儲那些存儲的數據。對於這種情況,用戶和主持人從用戶繼承,(強烈建議使用接口而不是繼承,可以很容易地擴展你的角色),問題,評論。爲了獲得與數據庫的交互並創建模型供你在控制器類中使用,你還需要一個數據訪問對象層,對於這種情況UserDAO,QuestionDAO,CommentDAO實現一個DAO接口。讓我繼續討論控制器,控制器是與模型和視圖進行交互的類,它只是對模型進行少量操作,並將它們提供給視圖,或從視圖獲取數據並對其進行處理,並提供給相關的DAO進行存儲。你需要一個SingupController,LoginController,QuestionController。例如,您從註冊表單的視圖獲取數據,然後在SingupController.singUp()方法中進行驗證,如果其有效,那麼您調用UserDAO來創建用戶行。我無法涵蓋所有​​的規格,但我只是提出了一個基本的設計。