Timeline for MVVM: Should the VM be a value type?
Current License: CC BY-SA 3.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 30, 2015 at 23:31 | vote | accept | Daniel T. | ||
| Jun 17, 2015 at 1:53 | comment | added | Daniel T. | So you are saying that Strings are immutable for good reasons, but none of those reasons apply to ViewModels? | |
| Jun 14, 2015 at 2:33 | comment | added | Robert Harvey | Well, simply that there are already some safety guarantees for strings. Did you read the conversation at the link I posted in my previous comment? Compare that with the inconvenience of having to set up a whole new View Model object from scratch if the user simply made a typing error. Then think about what you might gain from having an immutable View Object. Thread safety? How many people are going to be typing into that UI on that one screen simultaneously? | |
| Jun 14, 2015 at 2:32 | comment | added | Daniel T. | Hmm... I know I don't have to make the ViewModel immutable. I don't have to make anything immutable. Maybe if you could expand on the notion that immutable model objects render an immutable ViewModel unnecessary? I feel like the answer is in there somewhere. Thanks. | |
| Jun 14, 2015 at 2:08 | comment | added | Robert Harvey | Strings in C# (and many other languages) are immutable as well, for very good reasons. Doesn't mean you have to make the entire ViewModel object immutable... If anything, that strings are immutable makes it less necessary. | |
| Jun 14, 2015 at 1:14 | comment | added | Daniel T. | In response to the question, "you're not going to give people one chance, and one chance only, to enter data into a text box, are you?" In iOS, the NSString contained in a UITextView (the object that holds the data the user typed,) is immutable. This is, in part, the reason I'm confused about the issue. | |
| Jun 14, 2015 at 1:03 | history | edited | Robert Harvey | CC BY-SA 3.0 | added 161 characters in body |
| Jun 14, 2015 at 0:58 | history | answered | Robert Harvey | CC BY-SA 3.0 |