Git Product home page Git Product logo

Comments (5)

goneall avatar goneall commented on May 24, 2024

Yikes. A bit of a design flaw. Thanks @nicoweidner for pointing this out. This is probably a root cause of a few issues.

The change you proposed is very logical, but as you point out it is potentially breaking since the semantics.

I wonder if there may be another interface option that would preserve the existing semantics.

I was thinking of using the strict flag to force errors is the ID already exists, however, currently it can only be set after the ModelObject is created.

from spdx-java-library.

goneall avatar goneall commented on May 24, 2024

One thought is to add a new constructor with different semantics and deprecate the old one. We could add a strict parameter, for example. It would require, however, updating a lot of code.

The idea behind the strict parameter is, if it is set to true then the call will fail if the ID already exists. Otherwise, it would behave the way it does today. This is similar to how the library treats other checks on parameter validity.

I have mixed feeling about whether the strict approach is a good one. @nicoweidner - let me know what you think.

from spdx-java-library.

goneall avatar goneall commented on May 24, 2024

@nicoweidner I came up with another (partial) solution we could implement with low risk.

If create is true and there is another ModelObject in the store with the same ID, check to see if the type of the ModelObject in the store is the same as type type of the newly created ModelObject. We could fail if they are different types.

This would preserve the semantics of re-using an ModelObject even if create is true. It would prevent the non-symentric equals behavior mentioned in PR 112 comments.

I'm pretty comfortable no one would intentionally create a ModelObject with a different type expecting it to reuse the properties of a previous type.

The only case this doesn't cover is if someone accidentally creates 2 ModelObjects of the same type with the same ID.

from spdx-java-library.

nicoweidner avatar nicoweidner commented on May 24, 2024

@goneall Given the current situation, I prefer your latest suggestion of failing when someone tries to create an object with the same id, but of different type. That should prevent all the bad scenarios, and is little effort.

from spdx-java-library.

goneall avatar goneall commented on May 24, 2024

Fixed (mostly) with PR #121

from spdx-java-library.

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.