Giter Site home page Giter Site logo

Comments (7)

jubiiz avatar jubiiz commented on June 26, 2024

This process works when I only put either of the 'unique' or 'immutable' keywords: the code generates and compiles as expected.

from umple.

jubiiz avatar jubiiz commented on June 26, 2024

I have replicated this issue in Eclipse Version: 2023-06 (4.28.0), Build id: 20230608-1333
I was generating the code using the Umple plugin from http://cruise.eecs.uottawa.ca/org.cruise.umple.eclipse.plugin.update.site and compiling using

javac MyClass.java

from the /unique_immutable/src/java/ directory.
Here again, I was able to make this work if I only put either of 'unique' or 'immutable'.

from umple.

TimLethbridge avatar TimLethbridge commented on June 26, 2024

Thanks for this. I will assign it for fixing right away.

I confirm that if I paste your code into UmpleOnline, and hit 'Execute it', the same result appears.

Tijm

from umple.

TimLethbridge avatar TimLethbridge commented on June 26, 2024

Design option 1: In the generator, detect the combined case of immutable+unique and put the relevant code from the set method in the constructor in ONLY that case. This may make the generation template a bit more complex. I think this option should be tried first. New tests will have to be generated, but this should not break many (if any) existing tests.

Design option 2: For ALL unique attributes, instead of calling the set method, put the relevant code from the set method in the constructor. Drawback: Would slightly bloat the code of cases where the attribute is unique but not immutable, which may be common. This change will break all existing tests for generation of unique; those tests would have to be changed, which involves some risk that they are changed incorrectly.

Option 3. Disallow unique immutable with an error. This would not be reasonable.

from umple.

TimLethbridge avatar TimLethbridge commented on June 26, 2024

We discovered that if one uses 'unique lazy immutable' the code generated is much better ... the only issue is a missing argument to the constructor. So the suggested design approach (we can now call option 4) is this:

All 'lazy' does when combined with 'immutable' is that it gives one chance to set an immutable attribute.

With three keywords together the lazy create a setter method, even when the attribute is immutable, but that setter can only be used once. And the constructor in the case of unique would make that call. ... except that the constructor does not currently have the aruemnt

  1. In the parser, identify unique and immutable both being used together and set the relevant flag as though 'lazy' had been present, even if it was not. This can be done at umpleInternalParser_CodeClass.ump analyzeAttribute line 4717

  2. The relevant template is
    UmpleToJava/UmpleTLTemplates/constructor_AttributeAssignUnique.ump

  3. We need to ensure the template generates the argument for the unique immutable attribute is adding an argument in the following code <<=gen.translate("parameterOne", av)>> Normally this will generate an argument, but it seems it is not doing so perhaps because of the presence of 'lazy' (which if used alone suppresses the presence of an argument on the constructor to allow it to be set later). We need to work out the logic to ensure the argument is not suppressed ... perhaps we need to add a new variable for this special sort of 'lazy' status.

  4. The we need to add tests to make sure this works properly.

from umple.

TimLethbridge avatar TimLethbridge commented on June 26, 2024

This was solved with PR #2055

from umple.

TimLethbridge avatar TimLethbridge commented on June 26, 2024

Solved by PR #2055

from umple.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.