Timeline for Avoiding side effects in immutable class constructor
Current License: CC BY-SA 4.0
8 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Jun 16, 2020 at 10:01 | history | edited | CommunityBot | Commonmark migration | |
| Aug 13, 2019 at 1:12 | comment | added | candied_orange | Of course some imaginative things can be valid objects: null object, not applicable, no plate. | |
| Aug 10, 2019 at 14:58 | comment | added | Robert Harvey | A constructor should throw an exception if it cannot create a valid object. | |
| Aug 10, 2019 at 1:12 | vote | accept | jbruenker | ||
| Aug 10, 2019 at 1:11 | comment | added | jbruenker | Joshua Bloch does write "Classes should be immutable unless there's a very good reason to make them mutable." (his bold), but I suppose those are ultimately guidelines rather than laws. At this point the lowest cost solution by far is to just stick with what I have, so I suppose that's what I'll end up doing. Re: "effectfulness", maybe what I should have been thinking of is constructors being able to throw Exceptions? (Which of course can happen with DB queries) | |
| Aug 10, 2019 at 0:29 | history | edited | Robert Harvey | CC BY-SA 4.0 | added 87 characters in body |
| Aug 10, 2019 at 0:11 | history | edited | Robert Harvey | CC BY-SA 4.0 | deleted 144 characters in body |
| Aug 10, 2019 at 0:06 | history | answered | Robert Harvey | CC BY-SA 4.0 |