Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep Lifecycle methods together #3

Closed
passsy opened this issue Sep 26, 2017 · 1 comment
Closed

Keep Lifecycle methods together #3

passsy opened this issue Sep 26, 2017 · 1 comment

Comments

@passsy
Copy link
Contributor

passsy commented Sep 26, 2017

Our internal developer survey shows that our developers want to keep Android Lifecycle methods together (for Activities and Fragments), in the correct order and before all other methods. They should not be sorted alphabetically like all other methods. #6

survey

Why is this beneficial?

  • Activities and Fragments should not contain business logic instead those classes provide callbacks for the Android Framework. Those methods are called in special order. Having this order in code helps to know when things are ready to be called.
  • When sorting those methods alphabetical and mix them with all others, they can end up in wrong order (although it actually works most of the time) or mix with other methods which are completely unrelated.
  • Activity lifecycle methods are protected whereas Fragment ones are public. When grouping by visibility those from Activity end up after all public methods. Especially those should be moved right after the constructor.
@passsy
Copy link
Contributor Author

passsy commented Sep 26, 2017

Implemented: c5a13f5

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant