Yes, your suggestion is better. Not only cleaner, but also more performant: in the first case the cpu will speculatively execute both branches. One of them will fail and that execution pipeline will be discarded. Not a big deal, happens all the time, and branch prediction is very good these days, but if the conditional can be avoided, the cpu can continue to make progress. If you can choose, prefer math to branching code.
Sent from my iPhone > On 2016/06/18, at 4:50, Gary Gregory <garydgreg...@gmail.com> wrote: > > Should this: > > private int getMinCount(final Strategy strategy) { > if (Strategy.DROP == strategy) { > return 0; > } else { // Strategy.RETAIN > return 1; > } > } > > be: > > private int getMinCount(final Strategy strategy) { > return strategy.getMinCount(); > } > > ? > > Seems more OO to me. > > Gary > > -- > E-Mail: garydgreg...@gmail.com | ggreg...@apache.org > Java Persistence with Hibernate, Second Edition > JUnit in Action, Second Edition > Spring Batch in Action > Blog: http://garygregory.wordpress.com > Home: http://garygregory.com/ > Tweet! http://twitter.com/GaryGregory