Enum State pattern for android
-
25-06-2021 - |
Pregunta
I'm trying to create a Enum STATE pattern so I can set the current state of my operations. In C# (i think) I used this pattern:
Enum State { STARTED, STOPPED, PAUSED };
State _s;
public foo() {
_s = State.STARTED;
}
I did read somewhere that you shouldn't or couldn't use Enum in Android. How can I replicate this design pattern in Android?
Solución
You definitely can use them. Android's libraries don't which probably perpetuates the myth/out of date advice. It's easy to switch from one to the other, so start with enums and only change if you experience performance issues, but I doubt you will.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow