Skip to main content
6 events
when toggle format what by license comment
Feb 21, 2019 at 8:29 comment added Flater [..] There may also be cases where the validation is not a globally correct rule and only belongs to a subset of code. E.g. people can have a 1 in their name, but when taking a particular action (e.g. generate an email address for them) will cause a person's name to be cleaned.
Feb 21, 2019 at 8:27 comment added Flater If it's a rule that a Person can't have an invalid FirstName, then it shouldn't be possible to have a Person in that state to begin with. This idea (whose intent I do agree with) tends to go out the door when you deal with serialization, which requires public setters and getters for properties. In these cases, rather than have an vague serialization exception, you're better off with an explicit and targeted validation (and subsequent error message) after the serialized data is instantiated, which means you can't just block object creation. [..]
Feb 21, 2019 at 3:04 comment added taylorswiftfan Thanks Errorsatz. Appreciate you being able to understand the message behind my question. So in this context, a mutable design is where the same instance is cleaned and returned, while an immutable design is where a new instance is created with cleaned data?
Feb 21, 2019 at 1:24 history edited Errorsatz CC BY-SA 4.0
added 11 characters in body
Feb 21, 2019 at 1:18 history edited Errorsatz CC BY-SA 4.0
added 161 characters in body
Feb 21, 2019 at 0:44 history answered Errorsatz CC BY-SA 4.0