Author Topic: How to add units of measure to attributes in UML  (Read 14740 times)

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
How to add units of measure to attributes in UML
« on: December 21, 2020, 06:04:40 pm »
Hello EA Experts,

I have a class with attributes such as:
-Height
-Weight
-Blood Sugrar Level

How can I add units of measure to these 3 attributes?
- ft and inch
- lb
- mg/dL (milligrams per decilitre)

Thank you.
Mo
Thank you to all the contributors who spread their knowledge and experience!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13256
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add units of measure to attributes in UML
« Reply #1 on: December 21, 2020, 06:50:48 pm »
Hi Mo,

What we usually do is create custom datatypes for things like that

You can have things like
- speed (m/s)
- distance (m)
- weight (kg)

Or even compound datatypes such as
- Volume ( width, height, depth)
- Address (streetName, houseNumber, postalcode, city, country)

The set the type of the attributes to the datatype you have defined.

Geert

Sunshine

  • EA Practitioner
  • ***
  • Posts: 1309
  • Karma: +120/-10
  • Its the results that count
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #2 on: December 22, 2020, 03:30:39 pm »
Geert is correct and that's the best way to do it but not the only way. Just to put another option out there;
The real simple way is to put in the notes description what the units are and use primary types like float, integer etc. depending on range and accuracy required.
Interesting to see the mix of imperial and metric measurements - must be the USA aye?
Merry Christmas.
Happy to help
:)

pvickers

  • EA User
  • **
  • Posts: 44
  • Karma: +7/-0
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #3 on: December 23, 2020, 01:51:01 am »
Just to add yet another option to the suggestions so far...

You could use a basic numeric datatype for the measurements and define an additional attribute to identify the unit of measure used.

This approach is followed with the PPDM data model.

Hope this helps.
Perry

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #4 on: December 24, 2020, 05:53:39 am »
Thank you so much, Geert, Sunshine and Pvickers for yoru responses.

I just want to make sure that I got that correctly. Would you please take a look at the embedded screenshot?

https://ibb.co/P6XsPCm

Thank you,
Mo
Thank you to all the contributors who spread their knowledge and experience!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13256
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add units of measure to attributes in UML
« Reply #5 on: December 24, 2020, 06:00:43 am »
Yes, that looks like what I meant.

The only issue I see is that you have modelled the zipcode as an integer.
I think you should only use numeric types if it makes sense to calculate with them (adding two zipcode values together makes no sense at all). If not use a string with additional constraints.

Geert

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #6 on: December 26, 2020, 05:34:46 pm »

The only issue I see is that you have modelled the zipcode as an integer.
I think you should only use numeric types if it makes sense to calculate with them (adding two zipcode values together makes no sense at all). If not use a string with additional constraints.

Thank you so much, Geert for confirming.

I just want to clarify why a zip code should be modeled as a String vs an Integer?
My understanding is that a real number is integer. string is text.
For example, the "age" attribute would be modeled as integer although adding two age values together makes no sense. Correct?

Mo
Thank you to all the contributors who spread their knowledge and experience!

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13256
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add units of measure to attributes in UML
« Reply #7 on: December 26, 2020, 05:48:44 pm »
The difference is that you can calculate with an age.

You can compare it to a fixed age such as pension age, or drinking age. You can calculate how many year until the person reaches this age, etc...
I can even imagine circumstances where you would want to add ages such as the calculate the combined age of a household. That could be used as a factor in calculating the insurance fee.

A zip code is simply a code, that in your region apparently contains only numerical characters. Other regions have letters in the their zipcode (e.g. the Netherlands).
Another reason might be that the code might be '0025' You can't do that with an integer as that would end up to be '25'

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #8 on: December 26, 2020, 07:21:23 pm »
I think you can make an own science about how addresses are constructed worldwide (there's a university teaching it 5 minutes north-east and 2nd tree right).

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13256
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add units of measure to attributes in UML
« Reply #9 on: December 26, 2020, 07:29:18 pm »
I think you can make an own science about how addresses are constructed worldwide (there's a university teaching it 5 minutes north-east and 2nd tree right).

q.
You lost me completely ???.

Is that me, or did you have a bit too much gluhwein yesterday ;D

Geert

qwerty

  • EA Guru
  • *****
  • Posts: 13584
  • Karma: +396/-301
  • I'm no guru at all
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #10 on: December 26, 2020, 08:42:18 pm »
Not really. I once attended a workshop at a worldwide acting company where we had to define the business object Address. Of course everybody knew some exotic way how addresses (and not only zip codes) are build around the world. The "tree" example is just one. We in Germany stepped from 4 to 5 digit zip codes some (many?) years ago. UK has a mixture of letters and digits. It's definitely a real science. I mean, there's a (fun) science about mis-build matches (https://www.berlin.de/kultur-und-tickets/nachrichten/5098123-2154924-ddr-streichhoelzer-im-museum-der-dinge.html, http://www.friederbutzmann.de/match.htm and a couple more - all in German). So probably addresology is also something taught 2nd tree right.

q.

Geert Bellekens

  • EA Guru
  • *****
  • Posts: 13256
  • Karma: +554/-33
  • Make EA work for YOU!
    • View Profile
    • Enterprise Architect Consultant and Value Added Reseller
Re: How to add units of measure to attributes in UML
« Reply #11 on: December 26, 2020, 09:34:22 pm »
I see. The Netherlands is also a cool example. they have zipcodes that usually identify a single side of a street.
So in the Netherlands, the combination of housenumber + zipcode is enough to uniquely identify an address.

That is in contrast to Belgium where its basically a big mess. A zipcode often refers to a community, but no always. Some (larger) communalities have multiple zipcodes, and other zipcodes span multiple communalities.
Not even zipcode + streetname is guaranteed to identify a street, as a street with the same name may exist in the two communalities that share the same zipcode.

Geert

EA_enthusiast

  • EA User
  • **
  • Posts: 172
  • Karma: +0/-0
  • I'm a lifelong learner
    • View Profile
Re: How to add units of measure to attributes in UML
« Reply #12 on: December 27, 2020, 06:46:14 am »
Thank you so much Geert and q. for your valuable insights.

Now, I got your point, Geert. Since I am in the US, I assumed that zip codes are always numeric values that's what I wanted to use integer.

You raised a very good point about calculating with an age!

I laughed out loud on your comment to q.  ;D

Thank you,
Mo
Thank you to all the contributors who spread their knowledge and experience!