Vote 1

Has there been any innovation in Computer Science in the last decade?

September 5th, 2008

I was having an argument with a friend from school, I met after 20 years. His point was in the last decade or so there hasn't been any real innovations in computer science.

Read more (167 words) »

Vote 1

Java: Why Braces in Finally?

August 29th, 2008

Why does finally have to have braces?

Read more (78 words) »

Vote 1

Why is Java import static brain dead?

August 29th, 2008

Let's begin with an example. Assume a class MQ is in the packageĀ  com.taragana.mq. The utlitiy class Util also belongs to the same package. I can import Util from MQ like this:

Read more (100 words) »

Vote 2

The Power of Ant (Build System)

August 27th, 2008

I am using Ant (Java based build system) for our project. Ant is an exceptionally powerful build system and should be the only build system you will ever need. You don't really need code monsters like Maven (or pile of …. as Bileblogger loves to say). With little effort here's what I achieved in few hours (aside from the obvious capability of compiling, running, building jar files etc.):
Read more (497 words) »

Vote 3

Java Quiz: Why StringBuilder Should be Used Instead of StringBuffer?

August 23rd, 2008

First tell me what is the best way to concatenate large number of String objects? Is it a + b?

Most Java developers know not to use a + b (+ operator) because of huge performance problems, they use StringBuffer instead. In fact I did some tests in the past which confirms this folklore. However some of you may not know there is new kid on the block - StringBuilder. Read more (116 words) »

Vote 4

How To Delete Property From java.util.Properties

August 23rd, 2008

This isn't a trick question. For a long time you couldn't delete a property from java.util.Properties class. In the recent versions too Java doesn't reveal that it has added the functionality. However as java.util.Properties now extends Hashtable, you can delete a property by:

Read more (67 words) »

Vote 2

Is Ruby very syntax rich? Do you like it? I don’t.

August 19th, 2008

I tried delving into Ruby couple of times in the past. Every time I had this weird feeling of what am I doing here when I am already very well conversant with a simpler language - Java, which gives me everything I need. Ruby just felt very syntax rich, may ways and interesting tricks to do stuff and so on.While these may be appealing to a script-kiddie, nice syntactical sugars do not help much in the long run or help you create robust code (unless you love flying whales and a service which fails every other day).

I am not afraid of developing CRUD interfaces nor do I find it time consuming. What value can I get from RoR? Every time I delve into Ruby & RoR, I come back feeling unsatisfied. What am I missing here?

Read more (315 words) »

Vote 1

Apache Ant: How To Set Property When Initially Unset

August 19th, 2008

Also: How To Flexibly Pass JVM parameters to Apache Ant Java (Runtime) Task

Apache Ant is an excellent Java based build & deployment system using XML configuration file. In Ant properties are extensively used to configure tasks, conditionally run targets and more. In short they are an intergral part of build system. My requirement was simple. I wanted to pass JVM arguments to the Java runtime. However sometime I wanted to invoke it without passing any special runtime arguments. Unfortunately jvmarg element doesn't like it when its value is an empty string or even a string with spaces. Finding no way to fool it, I then tried to find a way to set the property to something when it is initially not set (while invoking). This proved surprisingly hard to do. Here is an elegant (I think) solution I came up with. Read more (231 words) »

Vote 1

Apache Ant: How To Include Multiple Jar Files In A Single Jar File

August 19th, 2008

Apache Ant is an excellent and popular Java based build system. It has several built-in commands (tasks in Ant lingo) one of which allows you to create Jar file from your existing class file and resources. What if you wanted to include not just class files but selective contents of other jar files too and make a single big jar file?

Ant provides an undocumented way to include the contents of multiple jar files within a single jar file.
Read more (180 words) »

Vote 1

Db4o Note: Db4o.configure() != Db4o.newConfiguration()

August 19th, 2008

In earlier versions of Db4o we used Db4o.configure() to configure all Db4o database globally (across all ObjectContainer). However in 7.2 (and above) versions of Db4o Db4o.configure() has been deprecated and it is suggested to use Db4o.newConfiguration() instead. Unfortuanately they do not clearly mention anywhere that these two functions are not equivalent. I assumed they are equivalent like Db4o.set()is equivalent Db4o.store() or Db4o.get() is equivalent to Db4o.queryByExample().

Read more (201 words) »