2
votes

this is a scenario of small office. there is software projects and there is manager. manager is responsible for managing those projects

manager can perform below actions

  • create projects //createProject()
  • delete selected projects //deleteProjectById()
  • edit the details of a selected project //updateProjectById()
  • update his information //updateManagerInfo()
  • add qualifications //addQualificationToManager()

  • assign employees for s project //assignemployees()

  • check project deadline//isProjectDeadlinExceed()

i want to model this scenario in uml class diagram below there is manager,project classes with their attributes

manager class attributes

name
genaralInformation
educationalQualifications
salary

project class attributes

projectid
projectname
deadline
budget
assignedEmployeeList



to draw uml class diagram completely i need to place above methods(actions that manager can perform) among the manager class and project class

i,m sure following methods are belongs to manager class because manager can only perform those actions and also those methods not involve changing state of project class attributes.

createProject()
deleteProjectById()
updateProjectById()
updateManagerInfo()
addQualificationToManager()

but i'm not sure where to put below methods?

assignemployees()
isProjectDeadlinExceed()

because above actions can perform manager and also above methods are work on attributes(state) of project class where to put those methods ???

2

2 Answers

1
votes

I think you are missing at least one abstraction, that is the set of all projects. Let's call this thing a ProjectPortfolio. Then I would perhaps go with this design (in java syntax):

public interface ProjectPortfolio {
    Project createProject(...);
    Project findById(...);
}

public interface Project {
    void delete();
    void update(...);
    void assignEmployees(...);
    boolean isDeadlineExceeded();
}

public interface Manager {
    void updateInfo(...);
    void addQualification(...);
}

It seems to me you are trying to put methods into the Manager, because the manager is the one doing them. Usually methods should be on the object that is being acted upon (the "subject" of the action).

So, for example, if you want delete() a project, that method should be (barring other requirements) on the Project object.

Therefore when you want to createProject(), you have to find a suitable "subject" where that operation makes sense.

Think about it this way: You are inside the application, you are surrounded by objects, which are your friends with whom you are trying to make the application work. So you should ask yourself: Who can I ask to help me?. For example for createProject() can I ask one of my Manager object friends? No, because those guys just represent some real-world people, they don't know how to create a project. And Project objects represent a single already created project. Therefore you have to write a new friend called ProjectPortfolio, who knows about all projects. :)

0
votes

enter image description here The use case diagram shows your scenario in a user goal perspective, helping you to design your class system. It does not mean that every use case has to be mapped as method of the actor that fulfills the action ( even, the actor doesn't deserve a class!).
In my opinion,in your scenario, Manager calls methods in the Project class to fulfill his functional requirements. Making reference to the following class diagram class diagram

you can see that the functional requirements are satisfied. As an example,in this class system, to add an employee to a project a manager has only to call a method in Project, choosing into a list of projects that he owns.