Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Converter question / suggestion? #45
In interface Converter why is Class getType() not Class getType() ?
I added the following class to my project to get rid of some boilerplate:
Eliminating boilerplate is a noble goal, which I heartily support. One way to achieve this is to introduce a constructor in AbstractConverter which sets clazz, as you do in EasierAbstractConverter.
However, don't you just move boilerplate around by introducing the need for an extra no-arg constructor in an implementing class?
Looking forward to your reaction.
It's just a (potentially substantial) reduction in boilerplate. You add some number of characters of boilerplate in the constructor while removing 5 lines of boilerplate when overriding the method (4 lines of method + one blank line -- the exact number of lines, of course, depends on one's formatting and spacing conventions.
I noticed a substantial reduction in a method where I was consecutively setting converters for 4 or 5 fields.
There's also a slight improvement in clarity. I mis-typed my first sentence to you. The question should have read:
Why is Class getType() not Class getType()?
With K in the constructor, There's no confusing that K is what should be returned. When overriding getType with the , after not looking at it for a bit, I had to give a little thought to what class the method was supposed to return.