Using Rational Software Architect to do your code reviews

One of the really cool tools my current group uses is the Code Review feature in Rational Software Architect. I have always thought (and many may argue) that I write reasonably legible code. I try to stick to best practices, make it look clean, well documented and well constructed. Well, unfortunately the default code review did not think as highly of my code as I. It found some great things and I was happy to learn them and change my code for the better. One really great aspect of the code review is that it not only picks out things you may not know but since it is automated it will find things that are just plane mistakes. One of the rules we used was to not allow for the instantiation of a new Boolean object. This is a waste of memory and not needed when you have the static methods Boolean.valueOf().

From the JavaDoc it clearly states:

valueOf

public static Boolean valueOf(boolean b)
Returns a Boolean instance representing the specified boolean value. If the specified boolean value is true, this method returns Boolean.TRUE; if it is false, this method returns Boolean.FALSE. If a new Boolean instance is not required, this method should generally be used in preference to the constructor Boolean(boolean), as this method is likely to to yield significantly better space and time performance.

Parameters:
b – a boolean value.
Returns:
a Boolean instance representing b.
Since:
1.4

This is just one small example of what automation can give you. I did find many of the errors reported simply annoying because the automation doesn’t understand the context of the code however overall the tool is excellent and should be used by all teams that use RSA.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.