【问题标题】:MVC UML class diagram designMVC UML 类图设计
【发布时间】:2013-11-10 08:42:43
【问题描述】:

我应该设计一个类似于 stack over flow 的问答网站,以下是我希望在我的系统中使用的功能,

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 模型中提供一些想法/示例,因为这是我第一次使用这种架构。

谢谢你:)

【问题讨论】:

    标签: model-view-controller uml class-diagram


    【解决方案1】:

    根据您上面的说明,我仅了解用户模型行为取决于不同的角色。让我先解释一下 MVC 是什么,然后我将向您介绍一个解决方案。在每个数据依赖系统中,都有一个存储可以是数据库或一个 xml 文件。因此在您的代码中应该有对象表示存储的这些数据。对于这种情况下,从用户继承的用户和主持人,(顺便说一下,我强烈建议使用接口而不是继承,使用接口可以轻松扩展您的角色),Question,Comment 。要与数据库交互并创建模型供您在控制器类中使用,您还需要一个数据访问对象层,在这种情况下,UserDAO、QuestionDAO、CommentDAO 实现了 DAO 接口。让我继续说控制器,控制器是与模型和视图交互的类,它只是对模型进行很少的操作并将它们提供给视图,或者从视图中获取数据并对其进行操作并提供给相关的 DAO 进行存储。对于这种情况你需要一个 SingupController、LoginController、QuestionController。例如,您从注册表单的视图中获取数据,然后在 SingupController.singUp() 方法中进行验证,如果其有效,则调用 UserDAO 以创建用户行。我无法涵盖所有​​规格,但我只是建议了一个基本设计。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-11-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多