Norbert Nemes
unread,Mar 3, 2016, 8:12:23 AM3/3/16Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Clean Code Discussion
I would have all that ugliness in one class: the API gateway.
It would have nicely named methods like fetchWhatever with a nice lambda returning the object(s) you are looking for and an error (but not your custom api errors). It would probably have a sendWhatever method in the same patrern. This way your app has no idea what API its using to communicate, and as such, it is unaffected by changes to it. As an added bonus, if the version of the API classes change, you would only have to modify one class: the gateway. The gateway would be composed of 2 parts: one that serialized your object into a request, and an API manager that sends it. This latter one would contain the API gunk, and would be simple enough not to need testing.