OO Design is more about ‘Doing’ than ‘Being’

One of the most profound insights I have learnt about OO is that software design — the shaping of code & classes — is best informed by what processing needs to do, rather than the entities it goes between.

This makes sense on a fundamental level. The purpose of most software is to process & transform data. Algorithms (like quicksort for example) have the same structure, regardless of what data they’re processing. In short, design of the machine should be based on what does it do rather than what its inputs look like at rest. Continue reading

‘Advanced OO Design’ series

Real software sees entities (Customer, File etc) involved in multiple interactions. Simple OO examples model behavior in entity classes directly, but this becomes tangled as behaviors & interactions increase; and results in broken inheritance structures.

Instead of modelling these all in the entity, a more advanced OO approach considers separating behavior from the entity. We’ll consider key principles in this multi-part series. Continue reading

Value Types & List<int> coming for Java 10 ?

Oracle, with lead engineer Brian Goetz, have launched an experimental OpenJDK project to bring long-awaited features to the Java platform.

Major enhancements to generics & new ‘value types’ are planned. Highlights include:

  • Value Types;  highly-efficient small ‘objects’ without inheritance.
  • Reified Generics;  retaining their actual type at runtime.
  • Generic Specialization;  List<int> would be valid & highly efficient.
  • ‘volatile’ enhancements.

The effort is named Project Valhalla. Here’s a preview: Continue reading

Explicit vs Implicit configuration in Spring

With the move to annotations for use of Spring, many projects have become based on component-scanning, auto-wiring and property-placeholder injection — an ‘implicit’ approach to configuration.

However, it can still be very useful to specify ‘explicit’ configuration. This gives us control of top-level application config & enables extensible configuration using the Strategy pattern.

Gaining control of configuration is crucial to enable per-customer/ per-application customization. Continue reading

Silent Thread death from unhandled exceptions

Threading is easy in Java, but today I was reminded of another of its pitfalls.

In Java- or container-provided threads, unhandled exceptions from our code will be printed or logged to the console. Create your own Thread or use SwingWorkerThreadPoolExecutor, and it’s a different story..

Threaded code tends to die silently. Nothing on the console or logs. Unhandled exceptions are invisible, and leave very few clues. Let’s look at why.

Continue reading