Continuous Deployment and the Unforeseeable

Posted by & filed under ContinuousDelivery, XP.

Can you afford not to do continuous deployment? Continuous deployment is the practice of regularly (more than daily) deploying updated software to production. Arguments in favour continuous deployment often focus on how it enables us to continually, regularly, and rapidly deliver value to the business, allowing us to move fast. It’s also often discussed how… Read more »

JSON to Java Interfaces with Nashorn

Posted by & filed under Java, JavaScript.

Here’s a neat trick to transform JSON into Java objects that implement an interface with the same structure. Java 8 comes with Nashorn – a JavaScript runtime that has a number of extensions. One of these extensions allows you to pass a JavaScript object to a constructor of an interface to anonymously implement that interface…. Read more »

Pattern Matching in Java

Posted by & filed under Java.

One of the language features many people miss in Java is pattern matching, and/or an equivalent of Scala case classes. In Scala we can match on types and structure. We have “switch” in Java, but it’s much less powerful and it can’t even be used as an expression. It’s possible to simulate matching in Java… Read more »

Delete your Tests

Posted by & filed under XP.

Tests, like any code, should be deleted when their cost exceeds their value. We are often unduly reticent to delete test code. It’s easy to ignore the cost of tests. We can end up paying a lot for tests, long after they are written. When embarking on a major re-factoring or new feature it can… Read more »

Java Value Objects

Posted by & filed under Java.

Java 8 not only gives us both default and static methods on interfaces. One of the consequences of this is you can create simple value objects using interfaces alone, without the need to define a class. Here’s an example. We define a Paint type which is composed of an amount of red/green/blue paint. We can… Read more »

Java Forwarding-Interface Pattern

Posted by & filed under Java.

Java 8’s default methods on interfaces means we can implement the decorator pattern much less verbosely. The decorator pattern allows us to add behaviour to an object without using inheritance. I often find myself using it to “extend” third party interfaces with useful additional behaviour. Let’s say we wanted to add a map method to… Read more »

Joins in pure-java database queries

Posted by & filed under Java.

I’ve been thinking about how to express joins in my pure Java query library. Hibernate and other ORMs allow you to map collection fields via join tables. They will take care of cascading inserts and deletes from multiple tables for you. While this is nice and easy, it can to cause problems with bigger object… Read more »

Thoughts from #pipelineconf

Posted by & filed under Conferences, ContinuousDelivery, XP.

This week I attended #pipelineconf, a new one-day continuous delivery conference in London. I did a talk with Alex on how we do continuous delivery at Unruly, which seemed well received. The slides are online here There were great discussions in the open space sessions, and ad-hoc in the hallways. Here’s a few points that… Read more »

Checked Exceptions and Streams

Posted by & filed under Java.

There are different viewpoints on how to use exceptions effectively in Java. Some people like checked exceptions, some argue they are a failed experiment and prefer exclusive use of unchecked exceptions. Others eschew exceptions entirely in favour of passing and returning types like Optional or Maybe. Whatever your view, you are likely to need to… Read more »

C# style properties in Java

Posted by & filed under Java.

One of the complaints that often comes up in any discussion on Java is getters/setters. If there are c# developers present they sometimes suggest that Java would be better off with c# style properties. c# properties, replace separate getters and setter methods that often clutter Java code. They allow the getters/setters to be combined together,… Read more »