When to prefer readwrite properties? [closed]
up vote
-1
down vote
favorite
I've often heard that readonly properties should be preferred but when do we prefer using readwrite properties. Generally, is it better to create a new viewModel with the new property changed or modify the property?
More concretely, let's say I have a selection view. When I tap on the view I update the viewModel. One way I could do this is to create a new viewModel with all readonly properties and the only property that differs is the isSelected property. Another option would be to modify the isSelected property directly. Why should I prefer one over the other?
objective-c properties immutability read-write
closed as primarily opinion-based by Amin Negm-Awad, Larry Shatzer, Willeke, lagom, Rob Nov 20 at 3:34
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
I've often heard that readonly properties should be preferred but when do we prefer using readwrite properties. Generally, is it better to create a new viewModel with the new property changed or modify the property?
More concretely, let's say I have a selection view. When I tap on the view I update the viewModel. One way I could do this is to create a new viewModel with all readonly properties and the only property that differs is the isSelected property. Another option would be to modify the isSelected property directly. Why should I prefer one over the other?
objective-c properties immutability read-write
closed as primarily opinion-based by Amin Negm-Awad, Larry Shatzer, Willeke, lagom, Rob Nov 20 at 3:34
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
up vote
-1
down vote
favorite
up vote
-1
down vote
favorite
I've often heard that readonly properties should be preferred but when do we prefer using readwrite properties. Generally, is it better to create a new viewModel with the new property changed or modify the property?
More concretely, let's say I have a selection view. When I tap on the view I update the viewModel. One way I could do this is to create a new viewModel with all readonly properties and the only property that differs is the isSelected property. Another option would be to modify the isSelected property directly. Why should I prefer one over the other?
objective-c properties immutability read-write
I've often heard that readonly properties should be preferred but when do we prefer using readwrite properties. Generally, is it better to create a new viewModel with the new property changed or modify the property?
More concretely, let's say I have a selection view. When I tap on the view I update the viewModel. One way I could do this is to create a new viewModel with all readonly properties and the only property that differs is the isSelected property. Another option would be to modify the isSelected property directly. Why should I prefer one over the other?
objective-c properties immutability read-write
objective-c properties immutability read-write
asked Nov 19 at 17:02
MichaelGofron
6162821
6162821
closed as primarily opinion-based by Amin Negm-Awad, Larry Shatzer, Willeke, lagom, Rob Nov 20 at 3:34
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.
closed as primarily opinion-based by Amin Negm-Awad, Larry Shatzer, Willeke, lagom, Rob Nov 20 at 3:34
Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes