How can I improve this UML class diagram?
I'm really confused about the relationship between Expense
and Category
, because Category
and Expense
can exist by themselves: you can register Expense
and not assign a category
,
you can add new Categories
to the categories
list, and so on…
Do I really need separate List classes?
Best Answer
Your UML diagram is ambiguous about the relation between
Expense
andCategory
:Category
instances related to oneExpense
. But the signature of theGetCategory()
suggests that there is only one possibleCategory
for a anExpense
Expense
side and 1..* onCategory
sidecategory
label on theCategory
side of the association, to convey the naming of the relation.Your diagram is ambiguous about the relation between
Expense
andExpenseOperationHandler
:Expense
is anExpenseOperationHandler
".Do you need
ExpenseList
andCategoryList
?instance
andgetInstance()
), so that there is only one such list, containing all the related items. In this case it depends of the purpose of your diagram: the answer would be no for domain modeling, but it could be yes, for design (e.g. you'd need these classes in you UI design) or implementation details.