As we all know enums are memory hogs and using them is considered bad practice in android. Enums is used everywhere in this library project. These should be replaced with integer constants instead. @vRallev
Where is this considered bad practice? I consider weak type declarations as bad practice and prefer strong types with a better type safety. The IntDef declaration is only a lint warning.
The library has 4 enums with a total of 14 instances. 3 enum declarations could be replaced with ints, the other enum would require objects nonetheless. So I could potentially save 3 enums with a total of 9 instances. I've read that one instance requires about 20 bytes and the enum array 16 bytes, so I could save about 228 bytes (I guess the classes itself aren't included, please correct me here).
If I would change the enums to integers, I could save about 200-300 bytes. The downside is that every app out there would need to update their code. Then it's also necessary to check the parameters everywhere: Is this a valid integer or not?!
I don't see the benefit here and the enums-matter debate is total fail in my opinion. I recommend reading the comments in this post. Especially Matthias K盲ppler's response nails it.
Proguard also generally discards the classes involved in enums.
@vRallev I suggest you watch this video on enums .
Most helpful comment
Where is this considered bad practice? I consider weak type declarations as bad practice and prefer strong types with a better type safety. The
IntDefdeclaration is only a lint warning.The library has 4 enums with a total of 14 instances. 3 enum declarations could be replaced with ints, the other enum would require objects nonetheless. So I could potentially save 3 enums with a total of 9 instances. I've read that one instance requires about 20 bytes and the enum array 16 bytes, so I could save about 228 bytes (I guess the classes itself aren't included, please correct me here).
If I would change the enums to integers, I could save about 200-300 bytes. The downside is that every app out there would need to update their code. Then it's also necessary to check the parameters everywhere: Is this a valid integer or not?!
I don't see the benefit here and the enums-matter debate is total fail in my opinion. I recommend reading the comments in this post. Especially Matthias K盲ppler's response nails it.