Association or Aggregation?

I’ve been discussing with my co-workers when we have to use Aggregation or Association in UML models. Martin Fowler in UML Distilled, 3rd Edition says aggregation is the part-of relationship. It’s like saying that a car has an engine and 4 wheels as its parts. But aggregation was included in UML to differentiate from association, because in pre-UML days people didn’t knowhow to differentiate them. But aggregation, as Fowler says, is meaningless. Jim Rumbaugh says “Think of aggregation as a modeling placebo”. Association is a way to notate a property in our classes, but you don’t manage the life cycle of the associated property, as the aggregation relationship do. The solid line between the classes define the way one instance of the associating class can execute methods (operations realizations) of the associated object. So, why to use aggregation?

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!