Programming interviews – observations, tips

For the past 2+ years, I’ve interviewed more than 150 people for different Java positions, from junior to senior+ levels. During these technical discussions, I’ve observed a number of strange patterns repeating over and over again. Some of these are really counter-intuitive, maybe I’ll be talking about these in a different post.

All these interviews were really, really different, but one thing is constant: people get scared once they have to solve a programming puzzle at the whiteboard. I remember how I hated these kinds of tests when I applied to my current company. My reaction was not any different from most of the candidates’ I talk with. The whole thing went like this: I told the interviewer how I hated these exercises, I mentioned how the problems were not realistic and finally, at the end of the exercise I complained about how I missed good old JUnit. As I mentioned, nowadays’ candidates are not very different and I usually understand them. I really thought the puzzle part had to be done to torture people, who already happen to be freaked out as hell, with their pulse above 180, and can’t even stop sweating.

Continue reading “Programming interviews – observations, tips”

Advertisements

Java 8 HashMaps, Keys and the Comparable interface

/**
* This post is intended to be a 101 quickie for the less experienced.
* It does not provide new or innovative ways of solving a certain problem,
* just summarizes a topic the way I see it.
*
**/

OONO1YLNOY

Java 8 is coming with a lot of improvements/enhancements compared to the previous version. There are pretty many classes that have been updated, HashMap -as one of the most used data structure – is no exception. In this post, we are going to discover a new, important feature that Java 8 brings to us in case of hash collisions.

Continue reading “Java 8 HashMaps, Keys and the Comparable interface”

Writing integration tests for RabbitMQ-based components

I’m writing this post after days of misery, reverse-engineering, github browsing and finding (sort of) clever ways to get yet one step closer to the goal mentioned in the title.

Before we dive into the topic, let me clarify a few things. RabbitMQ, an AMQP (advanced message queueing protocol)  compatible message oriented middleware, (in my understanding) has no in-memory message broker implementation. ActiveMQ, another AMQP compatible implementation, on the other hand does provide such a component – easy to configure and use. The problem is that ActiveMQ implements version 1.0 of the protocol, while RabbitMQ is on version 0.9.1, and the two versions, of course, are not compatible. That is the main reason one might need QPID, a third MOM implementation that comes with an in-memory message broker and is able to “speak” multiple versions of the protocol.

Continue reading “Writing integration tests for RabbitMQ-based components”

Work in the constructor anti-pattern

/**
* This post is intended to be a 101 quickie for the less experienced.
* It does not provide new or innovative ways of solving a certain problem,
* just summarizes a topic the way I see it.
*
**/

This is a topic many have already talked about (a lot), but it still pops up from time to time. Strangely enough, not only in case of junior developers. Continue reading “Work in the constructor anti-pattern”

BigDecimal gotchas

Today I’d like to share some hints on BigDecimals, how and when to use them, what to watch out for and how to avoid strange errors.

When to use them

I think this is the most straightforward of them all. BigDecimals should be used when exact results with arbitrary precision are needed for numerical calculations. Continue reading “BigDecimal gotchas”

Non object-oriented objects

I always feel uncomfortable when I encounter instances of certain classes in the codebase I’m working with. Perhaps uncomfortable is not the right word here; the whole situation is a huge paradox: objects that fail to behave in an object-oriented way. Of course I’m talking about classes like Tuple and Triplet (or whatever name they may have in different libraries). Continue reading “Non object-oriented objects”

POSTing multipart requests with RestTemplate

Some days ago I had to write a little client application to call a RESTful web service; my job was to upload some data, defined in terms of JSON, along with a picture (PNG format, but that does not matter for this time). These tasks are usually carried out with POSTing form/multipart messages to the endpoint – my case was no different, the server was expecting just that. I thought it would be easy and fast to throw in RestTemplate from Spring, but as it turned out, this simple task took me around 12 hours, a complete Sunday and a lot of pain (finally, Sotirios Delimanolis pointed me in the right direction on StackOverflow.com). As it seems, there is little amount of code examples out there, so I thought I’d post one here.

Continue reading “POSTing multipart requests with RestTemplate”