This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I prefer a static method call for initialization over a static initializer block, when possible:
I think the former is slighty more readable, especially when there's initialization code like that for more than one variable, and because init blocks tend to clutter up variable declaration code.
Just a slight preference.
Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
Jelle Klap wrote:I prefer a static method call for initialization over a static initializer block, when possible:
The second does have one advantage, which is that the block cannot be called more than once. (OK, calling the second one more than once doesn't really hurt in this case, but it's nice for the intention to be clear). I agree that the first is more readable, and that probably makes me prefer it.