Static class in Java (Android) - use or not use

后端 未结 3 724
小鲜肉
小鲜肉 2021-02-08 12:38

Recently I have started development in Java for Android.

My idea is to create one static class which will load ton of stuff on the beginning and store results for a life

3条回答
  •  自闭症患者
    2021-02-08 12:47

    The problem with your solution is that you're basically creating a huge stack of globals. It's sometimes unavoidable, but it has the same type of problems globals always have- you quickly end up with hard to read code that doesn't really have a good OO breakdown. You can use this, but use it sparingly- only with important data structures that are really going to be shared between many activities.

提交回复
热议问题