Usage of MVVM in iOS

waddup dude! 1a- You’re headed in the right direction. You put loginButtonPressed in the view controller and that is exactly where it should be. Event handlers for controls should always go into the view controller – so that is correct. 1b – in your view model you have comments stating, “show the user an alert … Read more

ViewModel with List and editor templates

Assuming you have the following models: public abstract class TableInputModel { } public class RectangleTableInputModel : TableInputModel { public string Foo { get; set; } } public class CircleTableInputModel : TableInputModel { public string Bar { get; set; } } And the following controller: public class HomeController : Controller { public ActionResult Index() { var … Read more

Activity with multiple ViewModels

According to the open/closed principle, you should create three different ViewModels. The complexity isn’t increased that much, and you are gaining the ability to move one ViewModel (or just reuse it) with the corresponding RecyclerView to the another Activity very easily. Of course, sometimes breaking rules makes sense – for example if you know, there … Read more

ViewModels or ViewBag?

Basically, Should everything be done through the viewmodel or is it Ok to also incorporate viewbag? Everything should be done inside a view model. That’s what a view model is. A class that you specifically define to meet the requirements of your view. Don’t mix ViewBags with ViewModels. It is no longer clear for the … Read more

ViewModel in Kotlin: Unresolved Reference

Include the following as a dependency: implementation “android.arch.lifecycle:extensions:1.1.1” The equivalent AndroidX dependency is: “androidx.lifecycle:lifecycle-extensions:VERSION” in where VERSION can be replaced for Current Stable, Beta or Alpha values given in this official link This dependency is for both ViewModel and LiveData and thus would not require you to give separate dependencies for the same either; i.e. … Read more

ASP.NET MVC – Database entities or ViewModels?

Definitely use view models in your views, and use something like AutoMapper to create view models from entities easily. Cons: Sometimes it feels like you are duplicating code, specifically, when the view model and the entity have the exact same properties Pros: You often need to represent an object in a simpler format (often called … Read more

WPF: how to signal an event from ViewModel to View without code in codebehind? [duplicate]

Some comments: You can use the weak event pattern to ensure that the view can be GC’d even if it is still attached to the view model’s event If you’re already switching multiple VMs in for the one view, wouldn’t that be the ideal place to attach/detach the handler? Depending on your exact scenario, you … Read more

Should a user control have its own view model?

Absolutely, positively NO Your UserControls should NOT have ViewModels designed specifically for them. This is, in fact, a code smell. It doesn’t break your application immediately, but it will cause you pain as you work with it. A UserControl is simply an easy way to create a Control using composition. UserControls are still Controls, and … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)