News for hackers. Stuff that matters.
Re:A bad citizen in Javaland (2006) by jlewallen on Thursday December 03, 2015 @10:04AM (#10669886)
This is great! I can't help but feel there's also an opportunity in a sequel to allude to the all too common "invent arbitrary abstract base classes to keep my code DRY" anti-pattern.
Re:A bad citizen in Javaland (2006) by jdmichal on Thursday December 03, 2015 @12:56PM (#10671201)
For learning purposes for those reading this, what would you consider the alternative?

I personally prefer just stuffing commonly used stuff into utility classes containing only public static functions. Makes them really easy to test, too.

Re:A bad citizen in Javaland (2006) by jlewallen on Thursday December 03, 2015 @02:25PM (#10671884)
Thanks for asking! My answer, of course, depends on the particular scenario. I've had success with simple static methods, especially early in a project. I'd also consider some kind of composition (has-a vs is-a). The latter can be especially nice as static methods gain complexity in the form of more parameters/variations. This also shines if there's meaningful alternative implementations that can be swapped or if you're writing business logic and some legitimate business concepts start to congeal out of the code being re-used.