Coding Pitfalls



To follov…

Use .equals() when comparing strings, not ‘==’, as the latter compares references not contents. So “Hill” entered by the user will be a different String instance to “Hill” loaded from a file.

…obviousnesses like trap nulls, empty collections, …


See the Java Hall of Shame: http://www.cs.arizona.edu/sumatra/hallofshame/

Beware multithreading. This is a complete topic in itself, but here’s an interesting note on double check locking, and why you can’t count on it working.

Similarly a general rant at http://www.jwz.org/doc/java.html, but includes some useful things to bear in mind if you’re getting deep in.

(AstroGrid 2002)


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: