Monday, March 10, 2014

Enums - what can go wrong?

In last two posts I showed you what enums in java can give us and what we can do with them. I hope that right now you will agree with me that enums are really powerful.

Today I want to present you a few things which you can treat as a warning sign whenever you will see something like this in your own code.
But you need to remember that it's just a sign, nothing more. It doesn't mean that you shouldn't solve your problems in presented ways, it would be enough to take a deep breath, look at code once again and then made decision if it should be changed or not.

On the end of my last post I asked a couple of questions about examples given by me. If there was something worrying in them? Were they good or not?
Today I will try to explain why I asked those questions and I will share with you my thoughts about problems that can occur when we are overusing enumerations.

Let's start :)

Friday, March 7, 2014

This powerful Enum - part 2

let's move on

Recently I wrote about basics of Enums and when we finally knows them, we can take the next step and look how powerful Enums in Java really are.
Today there will be more code, mostly covered with tests to prove that it works as I wrote :)