Git Product home page Git Product logo

Comments (4)

goneall avatar goneall commented on May 29, 2024

See SpdxFile for an example of the builder pattern. This pattern was introduced late in the development of the library. It would be nice to add this to some of the license classes that were implemented previously.

from spdx-java-library.

amCap1712 avatar amCap1712 commented on May 29, 2024

Hi @goneall, I have begun some work on this here. I'll add documentation and tests for this and then proceed to find other possible use cases for builders. Do you have more such cases for using builders in mind ?

Also, I felt a little awkward while adding the builder. The large number of possible arguments make sense for adding the Builder but having multiple public constructors in addition to it make the API of the class a bit confusing. It would be interesting to explore if the public constructors can be replaced with static factory methods for common use cases.

from spdx-java-library.

goneall avatar goneall commented on May 29, 2024

Hi @amCap1712 Thanks for taking this on.

One suggestion - In the other classes that use builders, I used a slightly different pattern where the builder is passed in as a parameter to a constructor for the class rather than having a method which returns the instantiated class from the builder itself (see

protected SpdxFile(SpdxFileBuilder spdxFileBuilder) throws InvalidSPDXAnalysisException {
)

Either (or both) approach is fine, but for consistency I would like to pass the builder in as a constructor.

Also, I felt a little awkward while adding the builder. The large number of possible arguments make sense for adding the Builder but having multiple public constructors in addition to it make the API of the class a bit confusing. It would be interesting to explore if the public constructors can be replaced with static factory methods for common use cases.

There may be some compatibility considerations for code which is already using these constructors. That being said, simplifying the code would definitely be a good thing and I would be interested in your proposal and thoughts.

Note that there are a lot of helper methods in ModelObject to create the model objects - I think this will be the dominant use case with the other constructors just being around for compatibility.
See

public SpdxFile.SpdxFileBuilder createSpdxFile(String id, String name, AnyLicenseInfo concludedLicense,
for an example.

from spdx-java-library.

amCap1712 avatar amCap1712 commented on May 29, 2024

I agree with you regarding the compatibility restraints. I noticed the library is still 0.6. I am not aware of how widely it is used and the status section in the README says that it is under development. If the library is mostly used in other SPDX projects, it might be easier to make an incompatible change.

For now, I'll just add the builder and be consistent with the other parts of the code. Later, once I am more familiar with the project, I'll try to come back to this and see if we have some room for improvement here.

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.