A
antonyliu2002
OO Design continued.
When we try to design a class, we try to think about what the objects
of the class can do, like quite many OO programming books say.
Let's suppose that we are gonna design a ProjectManager class and a
Project class.
Well, what can a ProjectManager do? I think s/he can
createNewProject, deleteProject, assignFundToProject, requestFund,
deleteFund, editProject, viewProjectList, etc.
What can a Project do? I don't know except some getter setter
methods. The reason I don't know about it is because a project is not
animate, thus I am not sure what action it can perform.
So, naturally, I put those named methods above (createNewProject,
deleteProject, assignFundToProject, etc.) into the ProjectManager
class, because I think those are the things that a ProjectManager can
do.
But my colleague told me that those methods should really go into the
Project class. I assume that my colleague is right, because I do not
have much experience in OO design. But, then,
1. Why does it make more sense to put those methods in the Project
class than in the ProjectManager class, giving the instructions of OO
programming textbooks?
2. If we move those methods into the Project class, then what can a
ProjectManager do?
I want to be a good OO designer, so, please do share your wisdom about
this. Thanks.
When we try to design a class, we try to think about what the objects
of the class can do, like quite many OO programming books say.
Let's suppose that we are gonna design a ProjectManager class and a
Project class.
Well, what can a ProjectManager do? I think s/he can
createNewProject, deleteProject, assignFundToProject, requestFund,
deleteFund, editProject, viewProjectList, etc.
What can a Project do? I don't know except some getter setter
methods. The reason I don't know about it is because a project is not
animate, thus I am not sure what action it can perform.
So, naturally, I put those named methods above (createNewProject,
deleteProject, assignFundToProject, etc.) into the ProjectManager
class, because I think those are the things that a ProjectManager can
do.
But my colleague told me that those methods should really go into the
Project class. I assume that my colleague is right, because I do not
have much experience in OO design. But, then,
1. Why does it make more sense to put those methods in the Project
class than in the ProjectManager class, giving the instructions of OO
programming textbooks?
2. If we move those methods into the Project class, then what can a
ProjectManager do?
I want to be a good OO designer, so, please do share your wisdom about
this. Thanks.