Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: ea1122 on November 21, 2025, 12:33:52 am

Title: How can an activity invoke a behavior defined in a subclass of its own class?
Post by: ea1122 on November 21, 2025, 12:33:52 am
Class A contains activity A() and a subclass B containing activity B().
But when A() calls B() a code error is generated:
   public void A(a, b) {
      // behavior is a Activity
      /*Warning: B - Invoking behaviors from other classes - Not Supported!!*/
   }
So how does an activity invoke a behavior defined in a subclass of its own class?
Title: Re: How can an activity invoke a behavior defined in a subclass of its own class?
Post by: Geert Bellekens on November 21, 2025, 12:55:25 am
Class A contains activity A() and a subclass B containing activity B().
But when A() calls B() a code error is generated:
   public void A(a, b) {
      // behavior is a Activity
      /*Warning: B - Invoking behaviors from other classes - Not Supported!!*/
   }
So how does an activity invoke a behavior defined in a subclass of its own class?
Don't you think it's a bit weird that a class knows about it's subclasses? I think that violates the Open/Closed principle

But regardless of that, apparently, as indicated by the warning messages, invoking behaviors defined in other classes (whether they are subclases or not) is not supported.

Geert

Title: Re: How can an activity invoke a behavior defined in a subclass of its own class?
Post by: ea1122 on November 23, 2025, 07:35:54 pm
Thank you for your reply!
If all activities must be defined in the same class as any invoking activity, should all activities be in the same class to permit them to invoke each other?
Separating classes permits grouping of related components, the main value of classes.
I much appreciate your help!
Title: Re: How can an activity invoke a behavior defined in a subclass of its own class?
Post by: ea1122 on November 24, 2025, 03:54:30 am
OK, I see my error.