Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo

Close

Instantiating with Composition

Help
2012-02-27
2013-04-29
  • Hello,

    I am facing a problem in the use of USE. Here is an example of the code I am using:

    class A
    end

    class B < A
    end

    class C
    end

    class D
    end

    two classes A is a supper class of B. The supper class A has copposition relation to class C and an association with D. That is:

    composition AC between
    A  role anA
    C  role theCs
    end

    association DA between
    D  role aD
    A  role anA
    end

    Now, the proplem is when instantiating the class A as follows:

    use> !create a:A
    <input>:1:0: Cannot instantiate association class `A' without participants.

    However, when I create an object of class A's specialization (class B), then it is OK. Also, I do not get a message when creating a new object of A in the GUI.

    Do you have any idea why this might occure?

    Thanks
    Mustafa

     
  • Lars Hamann
    Lars Hamann
    2012-02-27

    Hi Mustafa,

    when I use your example model in USE 3.0.2 all works fine.
    However, the error messages indicates that you defined A as an association class.
    Instances of association classes can only be created when also specifying the participating objects of the association:

    !create a:A between (p1, p2)
    

    Cheers!
    Lars

     
  • Hi Lars,

    I guess I abstracted out too much details from the actual complicated model that I am working on. This might be the reason why it worked with you.
    However, I do not have any association classes in my model, but still I get this message. I have a composition, on the other hand. Does the composition have any effect?
    Also, why I get the message only with the supper class A not with the subclass B?

    Thanks for your help.
    Mustafa 

     
  • Lars Hamann
    Lars Hamann
    2012-02-27

    Hi again,

    I had a look through the code and found the issue.
    Currently there is a bug, if an association has the same name as a class.
    I fixed it for the next release, but for now you need to rename eiter the class A oder the association A.

    Cheers!
    Lars

     
  • Hi Lars,

    Thank you very much. This actually fixes the problem. I spent a very long time trying to understand why my ASSL procedures to  are not working to instantiate the model properly. Now, I understand.

    Cheers,
    Mustafa