Introducing $ – the Java Static Constructor

So this one will probably be controversial.

I’ve been playing around with this idea for a while, really since I started using Ruby in a hobby capacity. ¬†When instantiating a variable in Ruby, let’s say a simple 2D point class, you would use the following syntax:

Whereas we all know that the equivalent Java instantiation would be

There’s something I like about that static style constructor in Ruby, especially when constructing a method argument.

Continue reading “Introducing $ – the Java Static Constructor”

Fluent Setters

What are Fluent Setters?

Lately I’ve been making all my setters in bean classes fluent, meaning they return this object and can be chained together.

Take the following bean which exposes a lot of fields.

In order to use this class with it’s default constructor we have to initialize it and then can call all the setters on the object.

Continue reading “Fluent Setters”