2

My question has two part

1) Does Enum cause performance issue in Android as it says here Android Developers or it does not have much effect as it says here

I am really confuse should i use enum in my app or not

2) If I use enum in my app. What will be the best practice to save that enum in firebase

FaisalAhmed
  • 3,469
  • 7
  • 46
  • 76
  • 2
    *should i use enum in my app or not* - what kind of question is that? Just use if if you need it, don't worry about performance impact, you won't notice it – Tim Sep 26 '17 at 08:42
  • https://stackoverflow.com/questions/45483531/android-replace-parameterized-enum-with-intdef – Don Chakkappan Sep 26 '17 at 08:42
  • 1
    @TimCastelijns why should i not be worried about performance impact ? – FaisalAhmed Sep 26 '17 at 08:43
  • 2
    `Avoid using "enum". Enum will double memory allocation than ordinary static constant, so do not use it.` Read https://software.intel.com/en-us/android/articles/tips-for-optimizing-android-application-memory-usage – IntelliJ Amiya Sep 26 '17 at 08:46
  • 2
    @TimCastelijns The problem is that the recommendations in that video are taken out of context. I've heard many an Android developer say "enums are wrong, don't use enums" without understanding the details. For one such detail: how much memory are you keeping through listeners for Firebase data? If you don't know that, why are you worrying about enums? For q2, see https://stackoverflow.com/questions/37335712/android-firebase-9-0-0-setvalue-to-serialize-enums/37357484#37357484 – Frank van Puffelen Sep 26 '17 at 08:56
  • @FrankvanPuffelen i understand that i should know thing in details. But there was a doubt that it kill my processes[app] when the system runs low on memory. – FaisalAhmed Sep 26 '17 at 09:33
  • 1
    I get that. Always think of the broader picture: how do you think the size of those enums compares to the size of the data that you're reading from the database. Also see my answer here: https://stackoverflow.com/questions/46418909/where-does-the-firebase-listeners-listen-to-ram-or-disk/46422431#46422431 – Frank van Puffelen Sep 26 '17 at 09:34

0 Answers0