Tagged with "design"

The Concurrency Of ConcurrentHashMap

Java's ConcurrentHashMap is an excellent point of study when learning about Java's Memory Model. It employs numerous techniques to provide lock-free reads while still guaranteeing safe publication of objects. This article represents my attempt to take the magic out of the ConcurrentHashMap implementation. ... read more

Impact Of Local Variable Declaration Location

Does the location of a local variable's declaration result in performance changes of a method? For example, will a String variable, s, declared outside of a loop exhibit "better" performance than when declared inside a loop? In Java, looking at a class' bytecode explains, irrefutably, why the answer is ... read more

Safe Publication Of Transient Members

A very common (and quite dangerous) tripping point I find in concurrent Java code is that of unsafe member publication of otherwise safely-published objects. Of course, concurrent code is difficult to get right and I occasionally find myself identifying the same mistake in my own code---but usually only after a ... read more

A Case Of Leaky State

Leaky state is among the most common artifacts I find in existing applications. It's a symptom of poor encapsulation and/or abstraction and typically tends to unmaintainable code. Such symptoms are typically, but by no means exclusively, seen in an anemic domain model. Controlling state by means of encapsulation ... read more