Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » How to make an instance specification of a structured datatype in an UML profile
How to make an instance specification of a structured datatype in an UML profile [message #1758311] Mon, 27 March 2017 14:53 Go to next message
Benedikt Bauer is currently offline Benedikt BauerFriend
Messages: 11
Registered: March 2017
Junior Member
Let's assume I want to build a UML profile for my hypothetical shirt factory. Since I'm not a custom tailor but produce only some fixed sizes, I have a very limited set of sizes and for every size, several other parameters such as collar width, sleeve length and the like are directly correlated to each size. For example, a size M shirt has collar width a and sleeve length x, while a size L shirt has collar width b and sleeve length y and so on.

Now I would like to create a steretype "shirt" with one of the assigned properties being the shirt size as an enumerationof all my shirt sizes from S to XXL to choose my size. However, the enumeration shall not only contain the string literals S to XXL but also the dependent other values.

My current approach is to have a class stereotype "shirt" and a data type "shirtSize", which has the properties "collar width", "sleeve length" and so on. Then I want to create an instance specification for every one of my sizes where I specify the values as they are defined in my "shirtSize" data type. For that, I create an instance specification named according to one of my sizes, e.g. "M" and typed with my "shirtSize" data type.

Now, I would expect, that I can somehow access the properties that are defined in the "shirtSize" data type to assign actual values to them. However, I can't find such a possibility. Can someone give me a hint or tell me whether I just have taken a wrong turn somewhere in my thought model?

Thanks a lot.
Re: How to make an instance specification of a structured datatype in an UML profile [message #1758331 is a reply to message #1758311] Mon, 27 March 2017 17:27 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5580
Registered: July 2009
Senior Member
Hi

Define your derived properties as derived properties with OCL (or ...) expressions to define your computations.

Regards

Ed Willink
Re: How to make an instance specification of a structured datatype in an UML profile [message #1758363 is a reply to message #1758331] Tue, 28 March 2017 06:46 Go to previous messageGo to next message
Benedikt Bauer is currently offline Benedikt BauerFriend
Messages: 11
Registered: March 2017
Junior Member
Hi Ed,

thanks for the hint. Unfortunately, not all of my values are computable but there are also things like a "description" field. If I get your approach right, that would mean to create an enum for any field I need and then make sure via OCL expressions, that if I select a certain literal from one enumeration, the corresponding literals from the all other enumerations are set accordingly, right?

That seems a bit error prone to me...

Regards
Benedikt Bauer
Re: How to make an instance specification of a structured datatype in an UML profile [message #1758378 is a reply to message #1758363] Tue, 28 March 2017 08:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5580
Registered: July 2009
Senior Member
Hi

Your terminology is confusing. How can you hope to implement something that is not "computable"? Telepathic execution is not a very advanced field.

An enumeration is one approach, but there are alternatives.

In general you need to identify what is your necessary state and what is an appropriate representation, then identify what is your degenerate derived state and how that degenerate state is computed. If you have a determinstic algorithm you can probably program it in most reasonable languages. Whether you compute the derived state on the fly, cache it eagerly, or cache it lazily is another implementation option that can be influenced by volatile/transient settings.

Programs can certainly be error prone. Good programmers use techniques that exploit language facilities to detect errors at compile time sometimes fully automatically, sometimes with the aid of a bit of analysis.

Regards

Ed Willink
Re: How to make an instance specification of a structured datatype in an UML profile [message #1758397 is a reply to message #1758378] Tue, 28 March 2017 12:04 Go to previous messageGo to next message
Benedikt Bauer is currently offline Benedikt BauerFriend
Messages: 11
Registered: March 2017
Junior Member
Hi Ed,

looks like we had a different perception of "computable". using it your way, I can of course find an algorithm that determines y from x.

However, the things I had in mind was something like a "struct" in c, a "dict" or "namedtuple" in python or a rather simple class in most object-oriented languages, that just holds some values in an easily acessible way. IAL, a concept, that allows me to define an abstract thing -- for clarity I avoid terms like object, class, structure and the like -- to classify a certain type of information that always has the same type of elements.

As I have thought abit longer about my problem, it boils down to the question: When I create a UML instance specification of some object that has abstract member elements (attributes), I set this object as classifier of the instance specification. Now for me the obvious workflow would be to have some type of interface where I can assign actual values to the member elements defined in the classifying object. Instead, the only way I see is to generate and type all the instance values by hand, which -- in my opinion -- carries the whole idea of having a classifying object ad absurdum.

I hope my pain did get a bit clearer now.

Cheers
Benedikt
Re: How to make an instance specification of a structured datatype in an UML profile [message #1758398 is a reply to message #1758397] Tue, 28 March 2017 12:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5580
Registered: July 2009
Senior Member
Hi

Sorry. No clearer. Just more confused. In what sense is a "struct" not computable?

Perhaps if you provide some (pseudo-)code of what you are actually trying to do it might be possible to understand.

Regards

Ed Willink

Re: How to make an instance specification of a structured datatype in an UML profile [message #1758437 is a reply to message #1758311] Tue, 28 March 2017 16:50 Go to previous messageGo to next message
Camille Letavernier is currently offline Camille LetavernierFriend
Messages: 846
Registered: February 2011
Senior Member
Hi,

You should use slots in your instance specifications, which will reference the features (properties) of your classifier, and can hold values (hard coded or derived/computed) via Value Specifications (e.g literal string, literal integer)

The papyrus class diagram has a shortcut to "instantiate" an instance specification from a classifier : drag and drop a classifier on an instance specification. The IS will be typed with this classifier, and a slot will be created for each property of the classifier (including inherited ones)

HTH,
Camille


Camille Letavernier
Re: How to make an instance specification of a structured datatype in an UML profile [message #1758503 is a reply to message #1758437] Wed, 29 March 2017 11:51 Go to previous messageGo to next message
Benedikt Bauer is currently offline Benedikt BauerFriend
Messages: 11
Registered: March 2017
Junior Member
Hi Camille,

This was exactly what I was searching for. I already had found the first part of your answer, i.e. that I had confused instanceValues and slots. However, I was not aware of the possibility to just drop a classifier to an instanceSpecification to create the corresponding slots.

Thanks a lot for your help, problem solved.

Cheers
Benedikt
Re: How to make an instance specification of a structured datatype in an UML profile [message #1767099 is a reply to message #1758503] Fri, 30 June 2017 19:56 Go to previous message
Kurt Woodham is currently offline Kurt WoodhamFriend
Messages: 1
Registered: June 2017
Junior Member
Thank you thank you for blazing the trail on this one. I was creating slots for my second of two instance of a fairly complex classifier, and I knew there had to be an easier way.
Previous Topic:C code generation in Papyrus
Next Topic:edit text box doesn't work
Goto Forum:
  


Current Time: Fri Jan 19 00:09:35 GMT 2018

Powered by FUDForum. Page generated in 0.01932 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software