Author Topic: UML and Ada  (Read 2785 times)

minghia

  • EA Novice
  • *
  • Posts: 5
  • Karma: +0/-0
    • View Profile
UML and Ada
« on: October 22, 2019, 02:25:22 pm »
I have an Ada generic which I am trying to represent in UML using EA. I can work out how to set up the Template Parameters when the parameters may be subprograms. I'm guessing there isn't a standard UML way to do such a thing as this.

My other problem appears to do with how to represent an Ada variant record. This is similar to a C/C++ union except it can have common fields to all variants and the record has a discriminant which may identify which variant is the current one. I know I can represent this by a C/C++ union but it doesn't encompass the whole idea.

Are there any suggestions on how to resolve either issue?

Yours

Tony

Richard Freggi

  • EA User
  • **
  • Posts: 264
  • Karma: +9/-5
    • View Profile
Re: UML and Ada
« Reply #1 on: October 22, 2019, 04:05:52 pm »
UML is a language, so just translate.  But you need to translate the semantics, not the unique dialect of your programming language.

I recommend you explain what you want to capture in the model about the variant record etc. to a 12 year old. Explain it clearly including all the critical things the 12 year old needs to understand.  Write it down in English.  Then look up what you just wrote down in a UML book.  That should give you the answer you are looking for.

Works for me.

Eve

  • EA Administrator
  • EA Guru
  • *****
  • Posts: 7130
  • Karma: +77/-10
    • View Profile
Re: UML and Ada
« Reply #2 on: October 28, 2019, 09:43:24 am »
Conceptually I'd describe a variant as an abstract datatype that is specialized depending on the type of data you want to store within.
Eve

support@sparxsystems.com

maxh

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
    • SafeCode Consulting
Re: UML and Ada
« Reply #3 on: January 14, 2020, 10:27:48 am »
If you don't intend to generate code, I think there are some straight-forward approaches to modelling it.  It may be a bit more challenging if you do, since you'll need to develop the templates that agree with the techniques.

Presumably you are referring to generic procedures or functions, since the package would be naturally supported.   The solution I've seen suggested for C# is to wrap the function in a parameterized class.  I would apply a custom stereotype (e.g. <<generic function>>) to the class, then create a code generation stereotype that discards the wrapper.

I think a variant record fits the paradigm of a parent class where the variant portions are inherited classes.  Possibly using a <<variant>> stereotype for these, with the class name being the discriminator. Code generation might require storing them as inner classes within another <<variant record>> container.  Again, some custom code templates would be in order to get this to generate code.