Book a Demo

Author Topic: Virtual Aggregated State in UML  (Read 4528 times)

gluzm

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Virtual Aggregated State in UML
« on: February 28, 2008, 06:54:24 am »
Hi, I am trying to visualize a state of a class that is not physically stored in the class but is calculated. For instance having a class MotorBike as a composite of Engine, Wheels, etc...  Each of this class having an attribute Status with two possible values Ready or Failure.

The composite class MotorBike does have a Status attribute as well, but this one shall be calculated based on the states of all its subcomponents. Where the rule can be something like (if any of its substate is Failure then MotorBike.Staus is Failure)
See the pseudo code for illustration.


What is the best way to display this in UML StateMachine diagram?

Thank you
Jan

Code: [Select]
  class MotorBike
    {
        private Engine _engine;
        private Wheel _whellRear;
        private Wheel _wheelFront;
        
        //...some code bellow
    
        public int Status
        {
            get
            {                
                if (_engine.Status == Failure) return Failure;
                if (_whellRear.Status == Failure) return Failure;
                if (_wheelFront.Status == Failure) return Failure;
                return Ready;                                
            }
        }
    }

Rhadamanthus

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: Virtual Aggregated State in UML
« Reply #1 on: February 28, 2008, 08:28:08 am »
gluzm,

A state is a behavioral feature, not a structural feature; thus, the fact that the state is calculated, not stored, is irrelevant to a state diagram.

That being said, you can specify that the state of an instance of the composite class depends upon the states of its parts by using guards on transitions out of the state, or by creating substates within the state that account for the states of the individual parts.

gluzm

  • EA User
  • **
  • Posts: 24
  • Karma: +0/-0
    • View Profile
Re: Virtual Aggregated State in UML
« Reply #2 on: February 29, 2008, 07:57:08 am »
Yes, I wish I could describe it like you did. This is basically what I wanted to do. To show the dependence on the states of its subparts.

Thanks for the idea, I think I must have been sort of paralyzed not to see it.  :)  I guess I will just use the an OCL constraint on the transition, that will capture the logic of the if condition. I showed in the pseudo code.

Thanks
Jan