Tesseraction
MVVN w/ Dependency Injection: Best Practice
I guess some people have different variants of the meaning “business logic”. Some people might just think that business logic includes things like calculating certain values from model data, and store methods for that within the model. I guess because of the need for separation of concerns, people generally bring most of the other logic into services and then it’s just a matter of deciding which “layer” is going to use those services. Anyways, I’m gonna go ahead and close this thread
51 replies
MVVN w/ Dependency Injection: Best Practice
I guess that explains why I’ve heard some conflicting things regarding the role of the view model. I’m going to have to research those 2 flavors so I can decide exactly what route to take here. Thanks for all your help. It was very constructive
51 replies
MVVN w/ Dependency Injection: Best Practice
My application has “files” (really folders with some xml data in it). So it sounds like it might be a good idea to have all of the data structures inside of the model, and then provide a service that is just responsible for saving and loading data from “files” and creating new ones”. Then the view model layer could take that service as a dependency and use it to manage “files” and create model objects out of it using the data structures provided in the model layer
51 replies
MVVN w/ Dependency Injection: Best Practice
So the Model layer would mostly just be some structs and classes that hold data and provide some super basic utility methods for working with that data, and the view model layer is responsible for all of the logic pertaining to that data, including saving and loading data, interacting with APIs, etc? Of course this is all assuming that the view model layer is utilizing services to help with these things
51 replies
MVVN w/ Dependency Injection: Best Practice
I just learned that in an MVVM architecture, the view model layer should not be responsible for saving and loading data. The model layer should do that. So should I make the view model layer take that service as a dependency and then pass it on for the model layer through model object constructors, or should I be passing the service as dependencies directly to the model somehow?
51 replies
MVVN w/ Dependency Injection: Best Practice
you’re recommending making a static class with methods to provide instances of my serialization class? What would be the advantage of this vs using dependency injection, which I could use to hand off the service to specifically the ViewModel layer?
51 replies
MVVN w/ Dependency Injection: Best Practice
The project is only about a week old and I’m taking this opportunity to learn MVVM and DI, so that’s why I’m considering refactoring it to use a different approach. With that in mind, I might just make it a singleton like you suggested
51 replies
MVVN w/ Dependency Injection: Best Practice
It just seems cleaner to me if the class is being used only in the view model layer and is only given access to the objects that request it. That way I avoid any global issues that could happen down the line. It’s just a hunch
51 replies