Java Object Creation is Very Fast

I was recently doing a code review and suggested some refactoring to extract some behaviour into separate classes. A common question came up, “This code has to be fast so shouldn’t I avoid object creation?” My instinct is always no, ignore those considerations when coding, let the compiler handle it until proven that you have to step-in. This time I avoided my laziness and cross checked that instinct. The top result on a quick search said that object creation should be avoided due to expense, but mentioned a Pentium II so I was suspicious. I’m not going to link to [Read on…]