-
Notifications
You must be signed in to change notification settings - Fork 217
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
Refactor code based on review #3
Conversation
I was reading your blog post and I wanted to place a question. Since there's no way to comment (I don't use Twitter), and no "issues" tab is available in this repo, I'm going to comment on this pull request. Hope you don't mind ^^. Instead of:
Couldn't we just (I use Dagger and Data Binding):
What do you think of this? |
First of all, I've now added an Issues tab over there for discussions, didn't realize that GitHub doesn't have one for forks by default (which I believe is what happened?). And yes, sure, lazy initialization of a ViewModel makes sense, and should work perfectly fine! If that's how you use it, and it works for you, there's not much of a reason to change it. However, since I know that I'll be using it at some point anyway (thus never actually avoiding its creation), I would probably just initialize it at one known point in the code, which makes it easier to reason about. Plus (And then in my actual applications, I have ViewModel creation abstracted away by some base classes. so I never actually write code like this myself.) |
Yup all this kind of logic is abstracted in BaseClasses, normally my ChildActivities/Fragments, only have to "initViews" and manage the observe logic, etc. Thanks for your input :) |
I've reviewed this code for the following article: https://zsmb.co/lets-review-pokedex/
These are the changes I'm suggesting in that article, take any or all of them as you wish! :)