Skip to content
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

Provide Default Constructors on Request/Response Classes #31

Open
ra-lukas opened this issue Jan 31, 2024 · 7 comments
Open

Provide Default Constructors on Request/Response Classes #31

ra-lukas opened this issue Jan 31, 2024 · 7 comments

Comments

@ra-lukas
Copy link

We would love to serialize the response objects to JSON for microservice integration. However, this is difficult given the response classes do not have default constructors.

Would you be interested in a pull request that integrates Lombok to provide no-args contructors and builders?

Or, would you be amenable to a pull request that simply provided no-args, default constructors?

@Gupta-Suruchi
Copy link

Hi, I'm working on a similar project, I would love to fix it.

@ra-lukas
Copy link
Author

ra-lukas commented Feb 8, 2024

@protonpluss For the time being, this is what we did, using Lombok.

@Data
public class QuoteResponse {
    private String symbol;

    private double open;

    private double high;

Then used MapStruct to copy over the data. https://mapstruct.org/

@crazzyghost
Copy link
Owner

@ra-lukas @protonpluss
By design, these response classes are intended to be accessed through standard getter methods. There are no publicly accessible constructors for clients to use, as the library handles data retrieval and class instantiation.

Serialization of the responses does not necessitate public constructors. You should be able to perform serialization tasks using and object mapper from an industry standard library (e.g https://github.com/FasterXML/jackson)

For deserialization I would recommend a similar approach to what you have taken but by managing app/service specific response classes decoupled from the library in your downstream services. This eliminates the need to include the library in any service that doesn't require calls to the AlphaVantage API, saves you some jar bytes, and provides greater control over the needed fields.

@ra-lukas
Copy link
Author

Serialization of the responses does not necessitate public constructors.

For deserialization I would recommend a similar approach to what you have taken but by managing app/service specific response classes decoupled from the library in your downstream services.

ROFL.

Because public constructors are THAT BIG OF A DEAL TO ADD.

@irodzik
Copy link

irodzik commented Sep 26, 2024

Serialization of the responses does not necessitate public constructors.

For deserialization I would recommend a similar approach to what you have taken but by managing app/service specific response classes decoupled from the library in your downstream services.

ROFL.

Because public constructors are THAT BIG OF A DEAL TO ADD.

Just doing some review of alphavantage libs and found this comment. Couldn't not answer to this ignorant comment. Loosening API by adding public constructors means extra place to maintain contract with API consumer. Also assuming on your response tone, that you are an expert, could you please explain why you do use library classes and tight coupling with library code instead of separating it from your application domain?

@ra-lukas
Copy link
Author

ra-lukas commented Sep 26, 2024 via email

@irodzik
Copy link

irodzik commented Sep 26, 2024

Best wishes and good luck to you too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants