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

Update the Request object with sensible defaults and access methods #13

Closed
thinkingserious opened this issue Sep 16, 2016 · 3 comments
Closed
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap

Comments

@thinkingserious
Copy link
Contributor

Issue Summary

In the Request we have:

public Map<String,String> headers;
public Map<String,String> queryParams;

set to null when the object gets instantiated.

This could definitely cause JAVA developer errors as they might assume the headers map to be at least instantiated and empty.

In fact in this example:

Map<String,String> requestHeaders = new HashMap<String, String>();
requestHeaders.put("Authorization", "Bearer YOUR_API_KEY");
request.headers = requestHeaders;

The user is forced to instantiate a new one and assign it while the developer could simply:
request.headers.put("Authorization","Bearer YOUR_API_KEY");

When playing with beans (such as Request), if you can avoid referencing externally complex objects it is better. In fact, I would suggest you to turn them private (or protected), add getters and setters, initialize them, and even make them final.

@thinkingserious thinkingserious added type: community enhancement feature request not on Twilio's roadmap status: help wanted requesting help from the community labels Sep 16, 2016
diegoc-am added a commit to diegoc-am/java-http-client that referenced this issue Oct 5, 2016
@diegoc-am
Copy link
Contributor

Hello, submitted a PR, what I'm not sure about is if we want to make all the variables in the Request class private and have setters and getters. Only updated the maps

@thinkingserious
Copy link
Contributor Author

Hi @belfazt,

I've added some comments to the PR. Thanks!

I would suggest we make all the variables private and have setters and getters.

diegoc-am added a commit to diegoc-am/java-http-client that referenced this issue Oct 6, 2016
diegoc-am added a commit to diegoc-am/java-http-client that referenced this issue Oct 6, 2016
@diegoc-am
Copy link
Contributor

Hi @thinkingserious,

I think I got to what you wanted

thinkingserious added a commit that referenced this issue Oct 7, 2016
…-default-13

Update the request object with sensible defaults and access methods, #13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: help wanted requesting help from the community type: community enhancement feature request not on Twilio's roadmap
Projects
None yet
Development

No branches or pull requests

2 participants