simonjwright / coldframe

ColdFrame generates Ada framework code and documentation from UML models.
https://simonjwright.github.io/coldframe
GNU General Public License v2.0
8 stars 1 forks source link

Unclear how to define initial instance populations #8

Closed AlexProudfoot closed 3 years ago

AlexProudfoot commented 3 years ago

In the Air Traffic Controller example that I've borrowed from Models to Code, the initial instance populations of the classes are part of the Domain Specification. I'm trying to use \<\<init>> operations to model this but it occurs to me that, in this case, the Duty Stations and Control Zones need to exist before the On Duty Controllers can be linked to them. Is there some way to specify the order of execution of the \<\<init>> operations? If not, how do I include the initial instance populations in the model?

AlexProudfoot commented 3 years ago

As an aside, ArgoUML doesn't seem to have a way of specifying class multiplicity (limits on size of instance population). Am I missing something?

AlexProudfoot commented 3 years ago

OK. I suppose this would be better phrased as "it might be helpful if there were a facility to define initial relationship populations and if the link creation were automatically invoked after the classes were initialised". What do you think Simon?

AlexProudfoot commented 3 years ago

In the meantime, I've tried using an init tag on the domain package but I notice that the procedure I provided is invoked before class initialisation.

AlexProudfoot commented 3 years ago

Hmmm. If the system initialised to all controllers off duty (which I think would be more reasonable) the problem would become one of making sure the Shift Specification instance was initialised before the Off Duty Controllers since the minimum break time would need to be known in order to put a sensible value (timenow - minimum break time) in the Last Shift Ended attribute.

AlexProudfoot commented 3 years ago

Oh. I expect what I need to do is convert \<\<init>> operations to normal class operations and create a domain initialisation procedure to call them in the correct order and then link the instances. I could put a description in the domain documentation.

AlexProudfoot commented 3 years ago

I hope you weren’t too bored by my ramblings Simon.

simonjwright commented 3 years ago

As an aside, ArgoUML doesn't seem to have a way of specifying class multiplicity (limits on size of instance population). Am I missing something?

«cardinality (max=n)»

simonjwright commented 3 years ago

I'm trying to use <> operations to model this but it occurs to me that, in this case, the Duty Stations and Control Zones need to exist before the On Duty Controllers can be linked to them. Is there some way to specify the order of execution of the <> operations?

The order is fixed, see the page on Initialization.

I suppose this would be better phrased as "it might be helpful if there were a facility to define initial relationship populations and if the link creation were automatically invoked after the classes were initialised".

Rather out of scope for CF, I think.

In the meantime, I've tried using an init tag on the domain package but I notice that the procedure I provided is invoked before class initialisation.

Class initialization is only needed for class variables & singletons. I’m not sure quite why I thought user-defined class initialization was needed. I regret ever introducing singletons!

I think there’s something missing with domain init procedures - you can’t ask them to be within the domain!

At the moment, in the House_Management example, I just put all the setup in the Lamp class here. It’d be much better in a domain setup procedure

I expect what I need to do is convert <> operations to normal class operations and create a domain initialisation procedure to call them in the correct order and then link the instances.

If that’s more comfortable, of course.

I hope you weren’t too bored by my ramblings Simon.

No worries!

AlexProudfoot commented 3 years ago

I think the best approach is probably to do all the instance and link setup in the domain init operation and not to hive off parts to class operations. Easier to see what’s going on, easier to document.