The Pragmatic Craftsman         :: Simplicity from complexity :: | About Me |

You are here: The Pragmatic Craftsman > Java

Go to: « Software Engineer: Best Job in America | My Job Went To India »

Assertions

Are you using them?

I only found out about them recently -- they've been available since JDK 1.4. I think they're vastly underutilized.... But they can be really helpful in debugging situations and don't incur any performance hit.

You can enable them in your JDK by adding "-enableassertions" to default VM arguments (type "jre" in filters in Eclipse and edit it there).

Then in your code, whenever you have a feeling "this can never be null or false" add the assertion, as in
assert thisField != null; and you're done.

Assertions are a great debugging tool.


Comments

Post a comment









Remember personal info?







Go to:
   « previous entry: Software Engineer: Best Job in America
   » next entry: My Job Went To India

Random Quote

Search

 

Topics

Architecture & Design :12
Better Coder :29
Books :43
Books Recommended :18
Buzzwords :5
Career :25
Craftsmanship :15
Java :15
Quotes :25
Recommended :9
Software Engineering :3
Uncategorized :33
Web Development :1

Archive

May 2008 (1)
April 2008 (2)
March 2008 (1)
February 2008 (1)
January 2008 (2)
November 2007 (1)
October 2007 (3)
August 2007 (3)

...since January 2002

Currently Reading


:: See list of books I finished reading

Info

© 2001-2008 Stanley Kubasek About me :: Contact me