New answers tagged

1

Your solution is exactly how this problem should be solved. And it truly is called a Factory. Yes, things get somehow messy when lots of dependencies are involved. Some more advanced IoC containers, like Unity, can create these kind of factories automagically. Well, according to Unity auto-factory with params , only Autofac can really do that out-of-the box....


0

I never call PropertyChanged directly, I use this very simple but extremely useful library: https://github.com/StephenCleary/CalculatedProperties/blob/master/README.md It is really a "formula engine" for MVVM that raises notifications from setters and for affected calculated readonly properties too (just like formulas in spreadsheets formulas react to ...


0

The colleague is wrong. Mutable state should be kept at minimum/normalized and what can be readonly/calculated should be calculated i.e. fewer setters is better. The only good excuse for denormalizing mutable state is performance tuning. As for INotifyPropertyChanged notificarions of readonly properties - do NOT raise them manually from trigger property ...


2

DRY principle prescribes to avoid duplication of different pieces of knowledge, not just repeatable blocks of code. Two identical blocks of code can correspond to very different rules and that's totally fine to have such "duplication". In this specific case, data required by view and data required by persistence layer are two different pieces of knowledge ...


0

As you are dealing with location, you should probably use the Lifecycle library, main use case of this library is for your use-case only. https://developer.android.com/topic/libraries/architecture/lifecycle And for the Permissions I would ask in activity and use Observer pattern to send the location updates to the view model.


Top 50 recent answers are included