-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Create a builder pattern for the objects that have longer parameter lists #3
Comments
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. |
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. |
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
Either (or both) approach is fine, but for consistency I would like to pass the builder in as a constructor.
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.
|
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. |
e.g. SPDX Listed License
The text was updated successfully, but these errors were encountered: