HttpClient and Web Sniffers


Introduction When I say HttpClient, I talk about a package i.e. org.apache.commons.httpclient in commons-httpclient. HttpClient is used for making post and get request to particular URIs. And one can all kinds of things with the response and response headers. A simple example of sending a: What’s strange with HttpClient? By default, a http request sent using HttpClient is not captured by the web sniffers e.g. fiddler. I have no clue why that happens. But that is a pain in the ...
Generics And Parameter Type Hiding

Generics And Parameter Type Hiding


Generics is an essential ingredient for a extensible and crafty design. When used wisely, generics make a programming language look good. Spiderman has reminded us repeatedly that with great power comes great responsibility. With all the extensibility we might toss the whole point type safety if generics are not used carefully. The following is a discussion about a warning often encountered. Problem Statement : Lets think of a scenario where the issue could be reproduced. Think of a zoo which has ...
Validation API for Complex and Multiple Validations

Validation API for Complex and Multiple Validations


I designed a very simple validation API when I was learning about Builder Pattern. Now, I have improved the code and used it in a small project. The code is now- Generic Can return return objects Has support for compound validators Other improvements have been made; like readability and updating comments Please find the code @ https://github.com/73ddy/poc_trunk/tree/V0.1 Here is a gist of the code, in order to make it sound less boring. Please have a look, and point out my mistakes ...

Kth maximum element in unsorted collection


Finding the Kth maximum element in an unsorted array doesn’t seem to be a big deal. Because, we know that finding the maximum and if we keep on eliminating the largest element from the array. And this we will take us to the Kth maximum element in an array. But this solution is of order O(n2). Can it be done in linear way? Yes. Well, almost. Have a look at the following method written in Java. Generalizing into an algorithm ...

Item 15: Minimize Mutability


Confused what Item 15 is? Well, as I have already mentioned in my previous posts, ‘Items’ are 78 items mentioned in Joshua Bloch’s book ‘Effective Java’. Those, well versed with the items in Effective Java may read them as a reminder, rest can have fun getting to know things. Moving to the next item, minimizing mutability. But why reduce mutability, when mutability can mean giving control to someone who will be using your API. Well, with great power comes great ...