Search code examples
umlclass-diagram

Class diagram for a mini JEE project


I want to start a project in JEE and I need to confirm about my class diagram. I need to know if the methods used are correct and if the composition I used is correct or not.

This is my class diagram:

enter image description here

The project is about an online sales store, that wants to set up a management tool to sell products, and to manage its products. This tool must include the following features:

  • Identification module: identification of clients, managers, supervisors
  • Sales module: make purchases for users
  • Product Management Module: Adding / Deleting Products
  • Statistical module: visualization of sales statistics

Functional Specifications

It is necessary to act on the application, to connect to the application with a user ID and password. To facilitate its use and in order to avoid any mishandling thereafter, here is the solution:

User Profile:

  • The user will be able to visualize the products sold by My Online Races. The user can place an order, provided that he has registered with the site My Online Races.

Manager profile:

  • The manager will be able to manage the products:

    • Add / Edit / Delete Products
    • Add / Edit / Delete category
  • These data insertions can be made using CSV or XML files, but also through various forms on the website.

  • The manager will be able to view the sales statistics.

Supervisor Profile:

  • The supervisor can add managers whose roles are specified above.
  • The supervisor will be able to view the sales statistics.
  • The supervisor will be able to view all the actions performed by the managers, a sort of audit trail.

Well I wish to know already if you have remarks about my design. As well as I have a confusion for several methods, for example adding, modifying and deleting a product. Should I put them in the manager or product class? Is the composition I put correct or should I remove it?


Solution

  • Quick review of the diagram and advices

    First some minor remarks about class naming: Ordered should be called Order.

    The composition between Article and Order is just wrong (not from a formal view, but from the meaning it conveys). Use a normal one-to-many association: it would reflect much better the real nature of the relation between the two classes. Please take into account that a new article may exist without having been ordered, so it shoud be 0..* instead of 1..*

    +belongs and +do in the middle of an association are syntactically incorect. You should use a plain triangle instead (or nothing at all). The triangle should be oriented in the reading direction Person do |> Order and Article belongs to |> Category

    The methods seem ok. You do not need to add a suffix.

    How shall objects be managed (created/updated/deleted) ?

    A more advanced concern is not about the diagram but about how you want to organise persistence (i.e. database storage):

    • do you really want the object to be an active record, that is an object that adds, updates and deletes itself (to the database) ? It's simple to set up, works well, but makes the class dependent on the underlying database implementation and thus makes maintenance more difficult;
    • or wouldn't it be better to use a repository for each object ? In this case the repository acts as a collection that manages all the database operations. The domain object (Article, order, User, ...) then have nothing to know about the database, wich leads to more maintainable code.

    But this is a broader architectural question. If it's just for a first experimental project with JEE, you can very well use the active records. It's simpler to set up. Be sure however in this case to disambiguate the Add/Update/Delete on Person, since it currently may give the impression that any person can add anyone.

    Improvement of the model

    A final remark, again not about the diagram itself, is about the domain. Your model considers that an Order is about a single Article.

    In reality however, orders are in general about one or several articles: if this would also be the case here, your Order would become an OrderItem and the real Order would be inserted between Person and OrderItem. You could then make the relation between Order and OrderItem a composition (i.e: OrderItem is owned by Order, which has responsibility for creating its items, and the items have no sense without the related order).