2

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 ???

qwerty_so
  • 35,448
  • 8
  • 62
  • 86
Susantha7
  • 898
  • 1
  • 20
  • 38

2 Answers2

1

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. :)

Robert Bräutigam
  • 7,514
  • 1
  • 20
  • 38
  • [[ 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).]] ==> but class according to definition of the oop ,methods located in the class is Operation that class can perform - is it ...?? if not please provide the definition and it's source – Susantha7 Apr 30 '18 at 08:45
  • 2
    Yes, methods are the operations the class can perform. But, operations the class can perform are *not* necessarily the operations *the entity the class represents* can perform. So "manager can delete a project" does *not* mean the `Manager` should have a `deleteProject()` method. It means the `Project` should have a `delete()` method, because the `Project` is the subject of the operation. There is unfortunately no universally accepted "authoritative" source for the "definition of oop", so it makes little sense to quote somebody else on this. – Robert Bräutigam Apr 30 '18 at 10:48
  • yes you are right.... but why is that when we drawing the the uml class diagrams all the operations that the class can perform categorize as methods.there are lot of that kind of class diagrams are available ion internet – Susantha7 Apr 30 '18 at 12:18
  • I'm unsure what you're asking, could you please reformulate? – Robert Bräutigam Apr 30 '18 at 13:37
  • thx for help .... i found a solution for previously asked questions in this thread https://stackoverflow.com/questions/4010686/methods-in-object-oriented-design – Susantha7 Apr 30 '18 at 13:49
0

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.

Jul10
  • 503
  • 7
  • 19