August 15, 2014

Java SE UML diagrams

Some useful basic UML diagrams about the Java SE API classes. Created with PlantUML. (See more excellent UML diagrams about the collections in this blog entry.)

March 4, 2014

Create Graphs with Scripts

If you ever have spent hours with a drawing, dragging boxes and formatting arrows, you will appreciate the following possibility: Create your flow charts and UML diagrams with a script, and let a tool draw the lines. It has the following advantages:
  • You will not spend your time with drawing and formatting the elements and dragging them around. Instead, you can focus only on the pure information you want to document.
  • As a result you will have a small and platform-independent text file, which you can store like a source code, and even put in a version control system.
  • It is very useful to document the classes hierarchies since the syntax of the code (e.g. Java) and the syntax of the UML script is very similar.

February 23, 2014

Date and Calendar Members Are Modifiable


The Date and Calendar classes are mutable classes. If you use them as a class variable and return them via accessor methods ("getters"), the client class can modify them, even if they are private members.

February 15, 2014

HashMap vs. equals()


You might face exam questions asking what happens when adding certain objects to a map. For this you have to understand what the equals() and hashCode() methods do, what is the contract of the Map collection and how its widely used implementation HashMap works.

February 8, 2014

Simple Java Deadlock Example Explained


There are several good Java deadlock examples on the internet. I tried to write the simplest example which is readable and also executable. I used the deadlock example in the Java Tutorial, which I had to re-write, because it did not always produced a deadlock when executed with JUnit: