billSearch( ... ) : Bill
Unit testing API bindings are very hard. By the way, the API
implementation for OpenStates is in python-sunlight[1], these bindings
are for developers who wish to use the API (e.g. provide a jar that
you can invoke to chat with the OpenStates server), not the server API
implementation it's self :)
>
> Having said all of that, I would very much appreciate any feedback anyone
> has for me before I start inching forward on this. I'm a Java guy, but I've
> never really written a public API before and my current shop (and to some
> extent, my previous one too) mostly has the motto "working code wins; pretty
> code be damned". Of course, I try to use modern patterns and all that but
> without any critical review going on, well...
I'd be happy to help as much as I can :)
>
> IOW: I want to write to YOUR community's standards; I don't want to produce
> anything anyone would be embarrassed about later on. :)
>
> So, python guys or not, I invite any feedback/code-review you feel like
> offering.
> :)
Sounds awesome. Where do you think you'll be hosting this? I'd love to
watch it develop :)
>
>
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Open State Project" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/fifty-state-project/-/DDiQ4uwPx1cJ.
> To post to this group, send email to fifty-sta...@googlegroups.com.
> To unsubscribe from this group, send email to
> fifty-state-pro...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fifty-state-project?hl=en.
[1]: https://github.com/sunlightlabs/python-sunlight
Cheers,
Paul
--
I'm Paul.
I wasn't necessarily planning on testing the API-bindings per-se -- my plan was to inject test-data into my interface and make sure it creates the expected model as output. That way, as things evolve, I can be sure I'm maintaining backwards-compatibility and all that. Whether or not the actual API changes is another matter -- and you're right, I can see how it would be hard to test that.
Or, were you getting at something different?
> By the way, the API
> implementation for OpenStates is in python-sunlight[1], these bindings
> are for developers who wish to use the API (e.g. provide a jar that
> you can invoke to chat with the OpenStates server), not the server API
> implementation it's self :)
I'm not sure I'm following… are you suggesting I not use the REST API to accomplish the goal?
> I'd be happy to help as much as I can :)
>
I'm counting on it!
:)
>
> Sounds awesome. Where do you think you'll be hosting this? I'd love to
> watch it develop :)
>
I figured to just keep it here on GitHub. Suggestions, different idea?
Quick "?".... would it be best to only include the standard fields or to provide state-specific models so as to include the optional fields?
--
You received this message because you are subscribed to the Google Groups "Open State Project" group.
To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/1OyBCIGrRM4J.
To post to this group, send email to fifty-sta...@googlegroups.com.
To unsubscribe from this group, send email to fifty-state-pro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fifty-state-project?hl=en.
You don't have to choose, I think. You can provide one model that works for every state and has every field. Two possible approaches:* Have a property defined for every optional field that you know about, which users of your API client should expect to possibly be null and to plan accordingly, or* Have standard API fields in defined properties, and then toss every +-prefixed field into a HashMap<String,Object> for users that know what they're looking for.The second option has the advantage of automatically capturing new fields that the Open States team adds to the API, without having to update your code to handle any of them.The one issue I see (with either option) is handling when the Open States team "graduates" +-prefixed fields to standard fields. If you were to go with the HashMap approach, you may want to also make that hash a catch-all for unrecognized standard fields, and strip off the "+" from everything you put in, so that if "+short_title" becomes "short_title" on the server side, it doesn't affect anyone.
-- Eric
On Sat, Mar 17, 2012 at 9:54 PM, Brandon Gresham <bra...@thegreshams.net> wrote:
Quick "?".... would it be best to only include the standard fields or to provide state-specific models so as to include the optional fields?To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/1OyBCIGrRM4J.--
You received this message because you are subscribed to the Google Groups "Open State Project" group.
To post to this group, send email to fifty-state-project@googlegroups.com.
To unsubscribe from this group, send email to fifty-state-project+unsub...@googlegroups.com.
You don't have to choose, I think. You can provide one model that works for every state and has every field. Two possible approaches:* Have a property defined for every optional field that you know about, which users of your API client should expect to possibly be null and to plan accordingly, or* Have standard API fields in defined properties, and then toss every +-prefixed field into a HashMap<String,Object> for users that know what they're looking for.The second option has the advantage of automatically capturing new fields that the Open States team adds to the API, without having to update your code to handle any of them.The one issue I see (with either option) is handling when the Open States team "graduates" +-prefixed fields to standard fields. If you were to go with the HashMap approach, you may want to also make that hash a catch-all for unrecognized standard fields, and strip off the "+" from everything you put in, so that if "+short_title" becomes "short_title" on the server side, it doesn't affect anyone.
-- Eric
On Sat, Mar 17, 2012 at 9:54 PM, Brandon Gresham <bra...@thegreshams.net> wrote:
Quick "?".... would it be best to only include the standard fields or to provide state-specific models so as to include the optional fields?To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/1OyBCIGrRM4J.--
You received this message because you are subscribed to the Google Groups "Open State Project" group.
To post to this group, send email to fifty-state-project@googlegroups.com.
To unsubscribe from this group, send email to fifty-state-project+unsub...@googlegroups.com.
That sounds good. As long as you can strip off the + sign before you store it in the hash, you'll handle the graduation of experimental to standard fields automatically.
To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/aMqxETORFtUJ.
To post to this group, send email to fifty-sta...@googlegroups.com.
To unsubscribe from this group, send email to fifty-state-pro...@googlegroups.com.
That sounds good. As long as you can strip off the + sign before you store it in the hash, you'll handle the graduation of experimental to standard fields automatically.
On Mar 18, 2012 12:36 PM, "Brandon Gresham" <bra...@thegreshams.net> wrote:
OK, figured it out; whether or not it's a discrete-value, I can stuff it in the map even if it's not prefixed with a "+". But, if it's not a discrete-value, it will be a JSON-string; figure, that's better than nothing and the end-user can parse it if they want it. I guess I could iteratively parse over it and build additional nest map(s) that get shoved into my map... that way there's not a ton of JSON for the end-user to have to deal with.Maybe I'll circle back on that at a later point, though.
On Sunday, March 18, 2012 8:58:34 AM UTC-6, Brandon Gresham wrote:
Eric,OK, looks like I found a solution to option-2.I can use Jackson to auto-bind the standard fields and then declare a deserialization-handler that is triggered anytime Jackson finds a field that isn't declared in my Object -- in the handler I can get the field components and add them to the Object's custom-property map.Still need to play around with the potential to automatically-handle *NEW* standard properties, but I know I can at least handle optional-properties (ie: "+") dynamically, so that's pretty nice.
On Saturday, March 17, 2012 10:20:17 PM UTC-6, Eric Mill wrote:
You don't have to choose, I think. You can provide one model that works for every state and has every field. Two possible approaches:* Have a property defined for every optional field that you know about, which users of your API client should expect to possibly be null and to plan accordingly, or* Have standard API fields in defined properties, and then toss every +-prefixed field into a HashMap<String,Object> for users that know what they're looking for.The second option has the advantage of automatically capturing new fields that the Open States team adds to the API, without having to update your code to handle any of them.The one issue I see (with either option) is handling when the Open States team "graduates" +-prefixed fields to standard fields. If you were to go with the HashMap approach, you may want to also make that hash a catch-all for unrecognized standard fields, and strip off the "+" from everything you put in, so that if "+short_title" becomes "short_title" on the server side, it doesn't affect anyone.
-- Eric
On Sat, Mar 17, 2012 at 9:54 PM, Brandon Gresham <bra...@thegreshams.net> wrote:
Quick "?".... would it be best to only include the standard fields or to provide state-specific models so as to include the optional fields?To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/1OyBCIGrRM4J.--
You received this message because you are subscribed to the Google Groups "Open State Project" group.
To unsubscribe from this group, send email to fifty-state-project+unsubscribe...@googlegroups.com.
--
You received this message because you are subscribed to the Google Groups "Open State Project" group.
To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/nTHwyx6Bij4J.
To post to this group, send email to fifty-sta...@googlegroups.com.
To unsubscribe from this group, send email to fifty-state-pro...@googlegroups.com.
Hurm. Well, It's really clear you spent a great deal of time getting
this together, so before I start anything, thank you for your work!
One bit that I would have done differently would be some of the
mechanics of the library - IMHO it's up to the API wrapper to access
the server's URL, decode the response and populate a POJO, if we are
going the POJO route (which it looks like you are)
The way I wrote the python-sunlight binding is actually slightly
different, but I think it's approach might actually work here too -
There's an OpenStates object (instantiated as openstates) with a
couple of methods (openstates.bills(), openstates.legislators() ...),
which take a set of arguments to describe the fetch (e.g. -
openstates.bills(state="co"))
I know doing optional named params or overloading isn't fun, so
perhaps a HashMap<String> could work in it's place, or something.
This method in python-sunlight just returns a data structure as
decoded by the json library directly through, which reduces a lot of
complexity, and makes it easy for other people to use the data.
Sometimes too much abstraction is a bad thing(tm).
Returning the decoded data from the server might be better then
populating POJOs, since you'd have to create instance variables and
getters/setters for all the elements that *could* come back from *any*
state - or use a HashMap (or something) and compose that.
Simple is better ;)
>
> Note: the Bill class was written roughly in the Builder-pattern whereas the
> other sub-models were not. I like the Builder-pattern just so we know the
> objects are immutable, but in reality they are anyways (mostly) since I'm
> not providing any mutators (I think the only one deals with the
> optional-properties). Thoughts??? Should I expand the others to follow the
> Builder-pattern, drop it as unnecessary, or do something different?
Is there any reason you needed this pattern? I would have thought
(guessing from not reading the code) you you'd built a concrete
builder for each state (or something), and populated the POJOs (e.g.
OhioConcreteBillBuilder, etc) depending on the state, but I see it's
just one, so I was wondering why you choose to go that way.
I'd also consider adding the fetch mechanics into some top level
OpenStates object or something, and returning either a decoded
response, or some sort of array of Bill objects or something.
I could be missing something, it's been a while since I've done Java
>
> --
> You received this message because you are subscribed to the Google Groups
> "Open State Project" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/fifty-state-project/-/nTHwyx6Bij4J.
>
> To post to this group, send email to fifty-sta...@googlegroups.com.
> To unsubscribe from this group, send email to
> fifty-state-pro...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/fifty-state-project?hl=en.
Thanks again for your hard work!
--
You received this message because you are subscribed to the Google Groups "Open State Project" group.
To view this discussion on the web visit https://groups.google.com/d/msg/fifty-state-project/-/uCESl9e3cIUJ.
To post to this group, send email to fifty-sta...@googlegroups.com.
To unsubscribe from this group, send email to fifty-state-pro...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/fifty-state-project?hl=en.
Seconded (sorry for the ML spam, I just want to make sure I was as
clear as Eric here)
--
I'm Paul.