Re: Using Interfaces as States
Friday, December 6, 2002 02:57 AM
I've seen this idiom recommended somewhere else for the purpose of robustness, and I think it has merit. The development advantage is that it is superior to assigning states to static final ints, which can be a bad habit and result in the temptation to do comparisons with literal ints in other places in the code. Imagine what would happen, for example, if the definitions were changed.
As far as performance goes pointer comparisons should have good efficiency. The question is, compared to what. It will beat String comparisons every time (impressively). It will probably be roughly the same as integer comparisons though -- perhaps slightly slower.