You are browsing the archive for 2010 March.

Funny Java Code

25 March 2010 in articles by Regina ten Bruggencate

Some funny and not so funny code I found in code reviews.

Example 1:

String detail = getFaultDetail(ctx);
String fault = getFault(ctx);

log.debug("Fault: " + fault);
log.debug("Detail: " + detail);
log.debug("String value: " + String.valueOf(fault));
log.debug("String value2: " + String.valueOf(null));

Result:
Fault: null
Detail: null
String value: null
NullpointerException

Example 2:

String s = readReply(-1L, 500L);
if (s == null)
return null;
else if (advancedMode)
return s;
else
return s;

I think this is a clear case of not refactoring correctly or overthinking all your options a simple return of readReply(-1L,500L) would have been enough.

Example 3:

switch (intValue) {
default:throw new UnknownValueException(intValue);
case 0: case 1: case 2: doSomething(); break;
case 4: doSomething2();
case 3: doSomething3(); break;
}

This is very badcode. When the intValue is 4 both methods doSomething2 and doSomething3 are executed.
The question for a reviewer is do we want this or did someone forget a break after doSomething2();
When a unit test is also missing and specifications are hard to find updating this code is only
for the brave ;-)

Example 4:

String test="1234";
boolean contains = false;
if (test.indexOf(3) >= 0) {
contains = true;
}
System.out.println("Result: " + contains)';

The question is what will be the line printed and why?

Online Campaign: 5 things you can do to help Duchess

7 March 2010 in announcements by Clara Ko

  1. Check out the site and please give us some feedback
  2. If you are a Duchess member, log in and update your profile
  3. If you are a woman in Java technology and not yet a member, join us
  4. If you are not a member, subscribe to our newsletter – this enables us to reach those who are interested in receiving news about Duchess (members are subscribed by default)
  5. Share the link http://jduchess.org on social networking sites like Twitter, Facebook, Plaxo, Hyves, etc. On Twitter, follow jduchess and retweet our messages, use the #jduchess hashtag

Duchess Community Site Launched

in announcements by Clara Ko

Today, we are launching a new website – Duchess Community, a social networking site that enables members to connect with each other across the globe.

Features of Duchess Community include:

  • Friend Connections
  • Rich Profiles
  • Activity Streams
  • Private Messaging
  • Groups
  • Forums
  • Blogging
  • Multilingual Enabled

Each Duchess Chapter is set up as a group, but topic-related groups can be created by any logged in user. Forums can be accessed through groups or through the forum directory.

We are launching with an international audience in mind by enabling the site to be multilingual. For the launch, the site is set up to be displayed in Dutch, French, and Brazilian Portuguese. We are currently working with volunteers to complete the translations and enable more languages. Let us know if you can help.

All users from our old site have been migrated to the new Duchess Community site. If you are already a member, please log in and update your profile. Feel free to browse around the site and let us know what you think via twitter or email: duchess(at)jduchess(dot)org. We appreciate your feedback and suggestions.

Welcome Duchess France

in announcements by Clara Ko

Source: http://blog.xebia.fr/2010/03/03/creation-de-jduchess-en-france/

Please join me in a warm welcome to Duchess France – the newest addition to the Duchess Community.

After meeting a few ladies from Paris at Devoxx 2009, the events have been set in motion to create Duchess France. Duchess France is our first chapter outside of the Netherlands and is the first step in globally connecting women in Java technology.

Rough Translation:
What we wish for jDuchess is to build a community where women who work with Java can connect with each other and share their experiences and points of view. We want to build a social network to make women more visible in the Java community, and to enable them to participate at events like the Paris JUG, and other events and conferences. And perhaps also become a speaker and present at these events.

You can get in contact with Duchess France via Twitter, Google Group and LinkedIn. For more info, please contact ellene(dot)dijoux(at)jduchess(dot)org.