开发者

Class Design (UML Class Diagram)

开发者 https://www.devze.com 2023-02-12 22:43 出处:网络
Could somebody please give their input into the following scenario: I have an Administrator class and a Technician class (both extending a User class but that is besides the point). I also have a Repa

Could somebody please give their input into the following scenario:

I have an Administrator class and a Technician class (both extending a User class but that is besides the point). I also have a RepairJob class which represents an item through its varying stages of being repaired {received|being repaired|waiting for part, etc.}.

Only administrator users will be able to add a new repair job to the system and will also be able to view the status of all the repair jobs currently ongoing.

Technicians will need to be able to accept repair jobs from a view of the list of any repair jobs which have not yet been accepted by other technicians. Technician uses will also have to be able to update the status of a repair job accepted by themselves until it's ready to be returned to the Customer (another class).

An administrator will 开发者_运维问答be able to accept any repair job in the system, even those already accepted by a Technician at which point they will no longer be able to update the status of the repair job. (To take account of employees being off work)

My Question

Could somebody give me an insight into how you would collect together the RepairJob instances. I had thought at first that since the administrator user would be adding these instances that it would be a good idea to model the collection inside the Administrator class however the Technician class will also have to be able to access a limited collection of repair jobs. I had also though of creating a RepairJobs class which had the list and was available to either class but I'm not sure if this would be a good design.


I think it ought to be separate from Admin and Tech classes. RepairJob is for a single task; what you're describing sounds like a RepairJobManager that maintains a collection of RepairJobs and tracks their status. It executes your rules according to the Role of the particular User that interacts with it.

package model;

public class RepairJobManager
{
    private Map<String, RepairJob> jobs;

    public void add(RepairJob job, Role role)
    {
        // Only allow Admin to do certain things.
    }

    public void update(RepairJob job, Status status, Role role)
    {
        // Only allow Admin to do certain things.
    }


}


My DDD view: You need a RepairJobRepository which holds a collection of RepairJobs. Also you need a RepairService with operations like - create(RepairJob jobSpec) (add the created job to the repository) - assign(RepairJob job, Role role)

RepairJob need a method like updateStatus(Status newStatus, Person p)
You need to get p's role to validate if he could update the status.

0

精彩评论

暂无评论...
验证码 换一张
取 消