How to Eliminate Bugs Through High Cohesion

Intuition tells us that methods like these ones suffer from a distinct code smell: CompilationTask getTask( Writer out, JavaFileManager fileManager, DiagnosticListener<? super JavaFileObject> diagnosticListener, Iterable<String> options, Iterable<String> classes, Iterable<? extends JavaFileObject> compilationUnits ); Why is that so? Let's delve into this intuition. Here is an example from the JavaCompiler Javadoc: Iterable<? extends JavaFileObject> compilationUnits1 = … Continue reading How to Eliminate Bugs Through High Cohesion

Usability vs. Reusability

This blog post I've found from 2009 has a nice way of looking at the problem of comparing the ease of use with the ability to reuse. It claims that usability and reusability is always a tradeoff between building a heavyweight, coarse-grained software component with few dependencies (very usable) a lightweight, fine-grained software component with … Continue reading Usability vs. Reusability

The Dangers of Correlating Subtype Polymorphism with Generic Polymorphism

Java 5 has introduced generic polymorphism to the Java ecosystem. This has been a great addition to the Java language, even if we're all aware of the numerous caveats due to generic type erasure and the consequences thereof. Generic polymorphism (also known as parametric polymorphism) is usually maintained orthogonally to possibly pre-existing subtype polymorphism. A … Continue reading The Dangers of Correlating Subtype Polymorphism with Generic Polymorphism

The Visitor Pattern Re-visited

The visitor pattern is one of the most overrated and yet underestimated patterns in object-oriented design. Overrated, because it is often chosen too quickly (possibly by an architecture astronaut), and then bloats an otherwise very simple design, when added in the wrong way. Underestimated, because it can be very powerful, if you don't follow the … Continue reading The Visitor Pattern Re-visited