Book a Demo

Author Topic: StateChart on attributes: possible ?  (Read 5396 times)

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
StateChart on attributes: possible ?
« on: July 03, 2008, 06:10:57 pm »
Is it possible to define StateChart diagrams for single table attributes ?
(As far as I found out, you can only place StateCharts on tables itself.)

Greetings
Bernd

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #1 on: July 03, 2008, 09:03:41 pm »
I think you're stuck.

If it were a 'normal' class diagram you could always elaborate the class further using a collaboration diagram. Features could then be expressed in the alternate notation, as separate 'boxes.' This might allow a state model to be attached, if UML and EA would allow such an attachment to a feature at all.

There's no particular (structural) reason you could not try this with tables and columns, but EA might not pick anything up when it came time to generate DDL.

Another option (with class diagrams) might be to define the data type of the attribute as a class, then attach the state model to that. The attribute itself (in your original class) would then be given that data type. If you need to express a state model for specific instances you need to go back to the collaboration model or something, and express the state model for all the participants. If things get more complex that that, you are probably seeing a flag that you need to rethink your factoring of the design.

For columns you might be 'straddling' design phases. Perhaps you need to move your state models to class diagrams, then transform (in the MDA sense) the structural parts to a data model. The behavioral parts (including state models) would then be used to drive code generation via an add-in or something. Maybe these could transform into stored procedure code, which could be added to your data model during transformation.

David
No, you can't have it!

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #2 on: July 03, 2008, 11:43:36 pm »
Hello David,

it is about using "set Run State" and "set Object State" in Object Diagrams.

Using "setRunState", I can create values like "A = in work".
But I would like to select the value "in work" from the StateChart instead of entering state values manually.

Using "setObjectState", you can choose from a table StateChart, but not from the attributes. But this is only a table state, not attribute state.

In our models, we have several attributes with different states within one table. So we would like to model StateCharts for each attribute in one table. And when creating objects form tables, we would like to choose attribute values from the particular stateCharts.

Greetings
bernd

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #3 on: July 04, 2008, 12:03:48 am »
Could this be done with trigger values or something like that?
No, you can't have it!

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #4 on: July 04, 2008, 01:06:04 am »
what are "trigger values" ?

Greetings
Bernd

«Midnight»

  • EA Guru
  • *****
  • Posts: 5651
  • Karma: +0/-0
  • That nice Mister Grey
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #5 on: July 04, 2008, 04:20:27 am »
Trigger | State Machine Table Conventions in EA help.

There is a visible notation for these.
No, you can't have it!

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #6 on: July 04, 2008, 04:23:30 am »
gonna check this. Thanks again, David.

Greetings
Bernd

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #7 on: July 05, 2008, 12:13:01 am »
Bernd,

I'm not sure if I correctly understand what you mean, so maybe this is beside the point.

When you have a class with various attributes, all of which can have a finite number of values, than a state machine for that class would have a region for each of these attributes, and in each region it would have a state for each value that the corresponding attribute can have.

Now for an instance of your class you can only set one object state, and anyway you cannot create regions directly in a state machine diagram, because EA does not support it. The neatest thing IMO would be if EA let you associate a state machine (not a diagram, but a MACHINE element) to your class, give it regions, associate the attributes with the regions, and in an instance let you set an object state for each region.

But this is just a dream.

In reality all I can think of is this (David already mentioned the general idea): Create enum classes, give them each a state machine diagram with states representing the values they can have, and give your class an association to each enum class. In the object diagram (or wherever you want to show your instances) create an instance of the class and an instance of each enum class, associate, and set each enum class instance the desired object state from its state machine diagram.

Frank

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #8 on: July 05, 2008, 12:58:51 am »
Thanks folks,

it simply overloads my diagrams, if I create subelements for each attribute. It would be a nice feature, to create StateCharts on each attribute.

Greetings
Bernd

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #9 on: July 05, 2008, 03:08:01 am »
Quote
it simply overloads my diagrams, if I create subelements for each attribute.

I wouldn't like to do this either. That's why I would like to have the possibility to relate attributes to concurrent state regions, which I think would be more logical than relating state machines to attributes. And more general at that, because a state machine diagram for the whole class could show more than separate state machines for the attributes.

What with EA not supporting this, I would simply leave attributes out of the class  when they can be represented by a region in the class's state machine, and of course leave methods out which can be represented by triggers. If I wanted to create code from that, I would have to either use automation, or define a transformation which replicates all classes, plus enum classes for the regions from the state machine, and gives the original classes the regions from the state machine as additional attributes and the triggers as additional methods, and create code from there. If it is possible at all to see the state machine in this transformation language I have never used.

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #10 on: July 05, 2008, 01:46:21 pm »
Hello Frank,

this only works, if your attribute states are correlated. For example, if you have a field "status" (new, in work, tested, finished) and a field "tolerance" (0,1,2 ...10), these two fields have no relationship. I cant imagine how to create one common diagram for two aspects which have no correlation.

IMHO it would be better to associate not only elements but also attributes with StateMachines.

Greetings
Bernd

Frank Horn

  • EA User
  • **
  • Posts: 535
  • Karma: +1/-0
    • View Profile
Re: StateChart on attributes: possible ?
« Reply #11 on: July 06, 2008, 12:54:06 am »
Bernd,

why should two aspects which are not correlated not live within the same state machine? It would only mean that there are no transitions from one region to another. And of course there can be many diagams within one state machine.
,
Anyway, if you want to have state machines on attributes and you can convince Sparx to support this, I certainly won't mind.

Actually I was jumping onto this thread because I've been preaching for months on end that Sparx should eventually implement a decent state machine support, and I don't want to miss an opportunity to make my point once more. The way it's implemented now, you create a state machine diagram and in the background EA creates a state machine element (which you don't see in the project browser and cannot edit), and within this state machine EA creates a region, which you don't see in the project browser either. So the UML 2 concept of state machines with regions is only half-heartedly supported, and EA tempts you to think in terms of UML 1 state charts, hiding the much more powerful and flexible UML 2 concept from you.

Perhaps if the UML 2 concept were made clear in EA, you wouldn't have asked for a diagram beneath an attribute ,but for an element to relate to the attribute, be it a state machine or a region.

A diagram is just a visualization, and a class should not be related with a state machine diagram, but with a state machine element. And I think that EA often blurs this by making you think in terms of diagrams where model elements are to be related.

Frank