source code bean

Archive for the ‘Java’ Category

19 Feb, 2013

Sometimes Java is just too verbose

Posted by: Peter In: Java

Sorting a list in Java: Collections.sort(list, new Comparator<SomeClass>() {     @Override     public int compare(SomeClass a, SomeClass b) {         if (a.getValue() == b.getValue()) {             return 0;         }         else {             [...]

05 Feb, 2013

Cleaning up JDBC bolierplate code

Posted by: Peter In: Java

Recently I have worked with a code base that has a lot of JDBC boilerplate code. The same code is repeated over and over again and can basically be broken down into the following pattern:   ResultSet rs = null; Connection conn =  null; PreparedStatement stmt = null;   try {     conn = [...]

At the first glance of String.replaceAll(String regexp, String replacement) it seems very obvious what the method does, and most of the times it does exactly what you want, but under some conditions it does not. Let me show you this by showing you a few unit tests I wrote recently when fixing a bug in [...]

19 Dec, 2012

Experiments with Play! Framework

Posted by: Peter In: Java|Web

As I wrote in my last post, I recently rewrote one of my hobby projects from ASP.NET MVC to Play! Framework. Play! was very easy to get started with, the only thing required was to have a JDK installed and to download the zip distribution of Play, unzip it to a directory and fire it [...]

So a lot is new since last time I posted. In the end of the summer I moved from Stockholm to San Francisco to start working for a company called Skout, building mobile social networks. With this new job some big changes came:) I am now back to coding Java after several years of mostly [...]

12 Apr, 2011

A simple image sprite generator in Java

Posted by: Peter In: Android|Java

For some time I have been playing around with writing games for Android. The game loads the graphics in form of image sprites, so I needed a way to easily stick several png images into one image. I though there would be tons of free applications available for this purpose, but I didn’t find any, [...]


Adwords

About

Welcome to source code bean! On this site I post stuff that I encounter in my job and spare time. The content is mostly related to .NET development, but my interest in techonology is very broad, so often you will find posts on totally different subjects!