Reputation: 41
Let's say we have a table of countries. Each country has a name, a short name and some kind of code, e.g. by ISO. In UML, I can model the country names as an enum, the short names as an enum and a third enum for the country codes. But then I always have to keep these three enums in sync. Bad idea.
So, how to I model this more elegantly? Is there a way to model 'tables' in UML or do I have to make these enums nested somehow?
Upvotes: 4
Views: 902
Reputation: 36305
You will model that via properties
The Country
class (I left out the attributes like name
) will return the country code via a property Code
which depends on the according enum. Other coding (with according naming) would be return in the same manner.
You need to decide on some leading coding (say it would be CountryCode
. In order to get other codings you would need to provide operations to either Country
or CountrCode
like asISO():String
and the like. This is a design decision. If you have independent codings which do not have mappings to each other you will run into trouble.
Upvotes: 1