r/programming • u/knife_sharpener • Feb 22 '15
Java Makes Programmers Want To Do Absolutely Anything Else With Their Time
http://www.forbes.com/sites/quora/2015/02/21/java-makes-programmers-want-to-do-absolutely-anything-else-with-their-time/
35
Upvotes
1
u/CyclonusRIP Feb 22 '15
httpPost.setDoc(xmlDoc); httpPost.addParam("username", "vip");
So what exactly does that mean? The entity of the post can contain many different formats. That's why is makes sense to create the concept of an entity. It's defensive programming. The user cannot use your interface to create some nonsense like I did above.
Also is that addParam a query param or a form param?
I guess maybe that design decision wasn't as dumb as you might think.
You shouldn't really complain too much about consuming the interfaces other people's libraries expose anyways. Your code should always use the ideal interface for your use case. If you are only consuming HTTP client to post forms then write an interface that is extremely geared towards that wraps the HTTP client.
Generally when I use ApacheHttpClient I am consuming a web service so I write an AppClient that maps all the APIs to simple method calls and abstracts the whole idea we're calling out over HTTP. My call would be:
appClient.login(username, password);
If you don't write the AppClient class or it's equivalent then it doesn't really matter what language or library you are using. You are going to have a really difficult time interfacing with a HTTP service.