Search This Blog

Tuesday, November 25, 2008

Interviews - A chance at playing god.

There are a few times where one gets a chance to directly influence the life of another individual substantially. If one is a judge, the statement is considered void and null, as it happens all the time. I am talking about a scenario where an interviewer that interviews a candidate and whose opinion and decision determine whether the candidate is hired or not.

I do interviews some times. I must however admit that I do not feel this as a moment of power by any means. I tend to put myself in an interviewing candidate shoes, here is a person who is either unemployed and desperately trying to find a job or a person who has let go a day of vacationing in the Bahama's in search of a better position for them and their families and I am tasked with providing my extremely valued decision of "Yes or No". As an interviewer, one must do proper justice to the interviewing process as one owes that to the organization on behalf of which they are conducting the interview, while still respecting the individual being interviewed and providing their best judgement.


That said, let me narrate a factual interview that occurred:

Candidate is seated awaiting the interviewer to come pick him up. The candidate is right outside the office of the interviewer. A lady storms out, another candidate interviewing for the same position, tears in her eyes. Clearly the interview did not go as expected. But tears in her eyes, that's quite disconcerting to say the least for our candidate.


Following suit, emerges the interviewer, stern faced, a no-nonsense type of character and beckons the candidate to enter. Candidate is already a bit disturbed by the plight of the previous candidate. The candidate now follows the interviewer into his room and takes a seat. The questioning process starts. Some standard questions and introduction are exchanged, no pleasantries, just formalities, before the meat of the interview starts.

Interviewer: I hope you realize, your CEO is a moron, he has done absolutely nothing for the company since he started.
Candiate: I must disagree with your assessment. It is my understanding that he has achieved all the goals that he set out to do and has in fact increased the revenue of our company by 20% during his tenure.
Interviewer: I still think he is a moron, anyway, lets go on. So tell me why should I hire you ?
Candidate: I have the relevant experience and skill required of this job, I am personable and have the confidence to execute the duties of this position well, I have good contacts, I..
Interviewer (interrupting): Your previous experience is of no value in this job as its a whole new environment. Regarding personality and confidence, my 10 year old son has the same attributes that you mentioned. Maybe I should take him for the position instead?
Candidate: That is your decision to make but I must hold my stance that he lacks the necessary experience that I possess.
Interviewer: I am not convinced, anyway, lets move on. So do you think you look good?
Candidate: I am no Tom Cruise but at the same time I consider myself presentable.
Interviewer: I am of the opinion that you look far better than Tom Cruise.
Candidate: I am flattered by your assessment and am glad that someone feel that way as my wife certainly does not (candidate trying to add some humor here).
Interviewer: If that is the case, I feel that you married the wrong person and you and your wife argue and fight a lot!
Candidate: This is the only topic we really ever fight about (still maintaining composure)
Interviewer: I am not yet convinced and still maintain that you are far better looking than Tom Cruise.
Candidate (Smiling): Thank you once again. If you would be so kind as to mention the same to the wife, it would eliminate our one reason for arguing.
Interviewer (Looking around the room): OK lets move on now. Give me 10 uses of a coat hanger within the next minute and a half.
Candidate (Answering with rapid fire): It can be used to hang a coat, draw a triangle, a weapon, remove cob webs........
Interviewer: OK, now tell me three good reasons to hire you as I am still not convinced.
Candiate: I have a lot of experience, I have excellent contacts, I have the drive and enthusiasm.
Interviewer: This is absolutely no good, everyone says the same thing. You have not even provided one good reason as to why I should hire you.
Candidate (At this point irritated): I have given you the reason why I believe that I am a fit for this organization. If you remain unconvinced, then, you are definitely entitled to your view. I, however have nothing else to add.
....
Some final statements and the interview ends. The candidate is taken outside to a cab by the interviewer. No smiles, no chilling after the interview, no return to earth, no small talk, just a goodbye.

So what happened? Do you think the candidate got an offer? You bet he did! Did he take it? Read on to find out...

Analyzing the interview, why was it so aggresive? This is clearly not a regular interview by any means. The interview was for a very senior position involving sales. The interviewer was apparently simulating a typical sales environment where he acted like a tough customer. The environment was to test how the candidate would perform and sell. It was a test to see how thick skinned the candidate is, how well he handles pressure, how composed he is and most importantly how he can defend his position and make a sale.

So, where does that leave the candidate? Does the candidate take the position? The candidate did not. The candidate although uncomfortable with the line of questioning, did understand the direction of the leading questions. However, the problem with the interviewer was his continued aggressive behavior after the conclusion of the interview. There was absolutely no way the candidate wanted to work with an individual with a personality like the interviewer. So the candidate turned down the offer and found a far more lucrative and suitable position in a different organization. The point of note here is that the candidate did not fail! The interviewer failed! He failed his organization as an interviewer as the deciding factor of whether the candidate accepted the job or not was really determined by the behavior of the interviewer. The interviewer lost a really good talent and the same could be equated to a $$$ of loss of the organization as they lost a really good sales person.

I think for a moment, as to how I would have reacted to the line of questioning. I must admit that I have a very transparent face and a far lower tolerance level. I would have been red within the first few levels of questioning and would have stormed out of the office after hurling some really choicest words at the interviewer. Would I have got the job, errr I doubt it :-).
I don't think I have the skin to be in sales. More importantly, I do not think I can tolerate people who would make others cry during an interview process. I do not believe that any individual, interviewing for a sales position or any other should have to undergo such a tortuous line of questioning. I also believe that as an interviewer or as a candidate, one should stick away from any topics that are personal in nature, such as marriage, family etc. Apart from being just plain territories that should not be charted, they represent food for law suits as well.

So, as a person conducting the interview, we have the power play, our opinion will count, regardless of whether it is a sole decision or is a collaborative one after discussing with other "gods". We can choose to intimidate, befriend or tread a path in between while interviewing the candidate. As an interviewer, one should control the interview session but not come across as rude. It is a balance. Remember that as an interviewer, one is representing not just one self but one's organization as well. What the interviewer portrays will be the impression of the organization for the candidate. From the perspective of the candidate, the keyword has to be "impress". Impress by personality or skill or both. As an interviewer on can easily judge the latter but the former is often a grey area. At best, I would rate gauging a candidate as a dark art. Remember that the candidate is assessing the interviewer and organization as well....Its a two way sale!

I must state one thing! I work at Overstock.com and the interviewing process here is so tangential from that mentioned above. Candidates who come to Overstock for interviews are treated with the utmost respect and hospitality. I joined the organization after all :-))))

Saturday, November 22, 2008

Home town of the Boss, jax-rs, jersey, spring, maven

I have previously tried jax-rs implementations by Restlet and JBoss RESTEasy. You can find the following same at :


One implementation that I had been postponing was Sun's RI, i.e., jersey. Trying to save 'hopefully' the best for last ;-). The name of the implementation has a part of the Boss's town of birth after all! Born in the USA! I am not born in the USA, but love it as much as my own country and is my home away from home! Moving on...

As before, I tweaked the simple Order Web Service example to use jersey.
  • Support for a Client API to communicate with Rest Resources.
  • Very Easy Spring integration.
  • Sun's RI, i.e., from the source
  • Support for exceptions
  • Very good support for JSON Media Type
  • Maven
  • Good set of examples
  • Automatic WADL generator
  • IOC
  • Embedded deployment using Grizzly
  • Filters on client and server side
  • Utilities for working with URI
One of the things that has impressed me about jersey is their out of the box JSON support. Being able to support JSON format without having to create a new javax.ws.rs.ext.Provider is rather convenient. By default the JSON convention is JSONJAXBContext.JSON_NOTATION. One can quite easily change the same to use Jettison or Badgerfish convention.

I was easily able to enable JSON representation for my Product resource by defining the Product data transfer objects with JAXB annotations, adding a @Produces("application/json") in the ProuductsResource class and ensuring that I have the jersey-json jar in my build.



ProductDTO.java
@XmlType(name = "product")

@XmlRootElement(name = "product")
public class ProductDTO implements Serializable {

....
}

ProductListDTO.java
@XmlRootElement(name = "productList")

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "products", propOrder = {"productDTOs"})

public class ProductListDTO implements Iterable<ProductDTO> {
....
}

ProductsResource.java
@GET @Produces("application/json")
public ProductListDTO getProducts() {

...
}






<dependency>
<groupId>com.sun.jersey</groupId>
<artifactId>jersey-json</artifactId>

<version>${jersey-version}</version>
</dependency>




There is an excellent tutorial, Configuring JSON for RESTful Web Services in Jersey 1.0 by Jakub Podlesak that you can read more about.

To support Spring integration, the web applications deployment descriptor has been modified to use the Jersey Spring Servlet. All the Spring managed beans defined by the @Component, @Service, @Resource annotations are automatically wired.



<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>

</context-param>

<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<servlet>
<servlet-name>JerseySpring</servlet-name>

<servlet-class>com.sun.jersey.spi.spring.container.servlet.SpringServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>





On the Client Side, I was pleasantly surprised by the ease in which I could invoke REST calls. As mentioned in my RESTEasy blog, jax-rs has no requirements for a client side specifications. However, those implementations that do provide one will be the ones to gain more adoption IMO. The jersey implementation provides a DSL like implementation to talk to the services. Very "VERBY", if there is no word in the dictionary like "VERBY", I stake my claim on the same :-). I modified the client from the RESTEasy implementation of the Order Service to use Jersey Client support as follows :



public class OrderClientImpl implements OrderClient {

private final WebResource resource;

/**
* @param uri Server Uri
*/

public OrderClientImpl(String uri) {

ClientConfig cc = new DefaultClientConfig();
// Include the properties provider

Client delegate = Client.create(cc);
// Note that the Resource has been created here

resource = delegate.resource(uri).path("order");

}

public OrderDTO createOrder(OrderDTO orderDTO) throws IOException {

return resource.accept(MediaType.APPLICATION_XML).type(MediaType.APPLICATION_XML)

.post(OrderDTO.class, orderDTO);
}

public void deleteOrder(Long orderId) throws OrderException {

resource.path(orderId.toString()).type(MediaType.APPLICATION_XML).delete();
}

public OrderDTO getOrder(Long orderId) throws OrderNotFoundException, IOException {

try {
return resource.path(orderId.toString())

.type("application/xml").accept("application/xml").get(OrderDTO.class);

} catch (UniformInterfaceException e) {

if (e.getResponse().getStatus() == Status.NOT_FOUND.getStatusCode()) {

throw new OrderNotFoundException(e.getResponse().getEntity(String.class));

}
throw new RuntimeException(e);
}
}

public void updateOrder(OrderDTO orderDTO, Long id) {

resource.path(id.toString()).type("application/xml").put(orderDTO);

}
}





As you can see from the above the use of the Jersey client API is rather straight forward and intuitive. One point to note is that Jersey provides a Exception framework for easily handling common exception cases like 404 etc. There are some classes that enable this support, com.sun.jersey.api.NotFoundException and com.sun.jersey.api.WebApplicationException that one can use. As I did not want to tie my data transfer object maven project to jersey in particular, I did not use jersey exceptions but instead stuck with my custom Exception Provider.

Running the Example:
The Example can be downloaded from HERE.

This example has been developed using maven 2.0.9 and jdk1.6.X. Unzip the project using your favorite zip tool, and from the root level execute a "mvn install". Doing so will execute a complete build and run some integration tests. One interesting thing to try is to start the jetty container from the webapp project using "mvn jetty:run" and then access the jersey generated WADL from http://localhost:9090/SpringTest-webapp/application.wadl

Now that you have the WADL, you should be able to use tools like SOAPUI or poster-extension (a Firefox plugin) to test your RESTful services as well.

It would be interesting to see how wadl2java and the maven plugin provided there in can be used to create a separate client project to talk to the web services.

The jersey web site has pretty good documentation about using jax-rs. It is not thorough but getting there. There are a good set of examples that one can download and try as well. It is my understanding that NetBeans has good tooling support for jersey as well.

So now that I have tried Restlet, different jax-rs implementations and jax-ws what would be my direction if I were to take a decision on what to use for my SOA project? Some food for my next blog :-)

Again, if the example fails to run, ping me...Enjoy!