Early abort idiom

Take a look at those Java code snippets:

public void insert(Order order)
   if(order != null) {
      // insert code here
   }
}

public void insert(Order order)
   if(order == null) {
      return;
   }
   // insert code here
}

The second code scratch is said to increase the Thomas McCabe’s cyclomatic complexity. The cyclomatic complexity is a model metric instead of implementation metric, as you may think. An example about implementation metric is LOC (Lines of Code). When I was in college, I learned the McCabe’s metric measures the number of control flow statements and return statements of your code, but it doesn’nt count the normal return statement of your methods. So, the McCabe metric is two for the first code and two for the second. McCabe says that the computation complexity rises with the increase of the execution routes. Cedric has an interesting opinion about this subject. Particularly, I think when you try to use the first insert(Order order), you end up having some nested if’s, your code tends to be a little messy. The second one focus on the basic flow of your method, that is, the normal bahavior its expected to have. In my daily basis, sometimes I apply the first one, sometimes the second one. And you? Do you think in cyclomatic complexity when you are coding?

Sun is gonna open source Java?

I’ve came across Vnunet to a interesting news that Jonathan Schwartz, Sun’s new CEO, said that Sun will release the source code of Java. One point of view is that this announcement would attract more developers to Java technology although this could lead to a lot of Java development communities, the same that occurs to the Linux OS distributions. On the other hand, this can be very interesting to developers who always wanted to explore the Sun’s JVM code.

Introducing myself

Hi! This is my first post on my blog. I’m a software developer and I’m here to share discussions on software development in general. I was graduated in Computer Science at PUC and nowadays I’m working as a Java software developer and doing a post graduation course on Software Engeneering at ITA, in Sao Paulo, Brazil. This blog is intended to promote some software thoughts and discussions. So, share with me your feelings with the software world!