Timeline for Is it an anti-pattern if a class property creates and returns a new instance of a class?
Current License: CC BY-SA 3.0
5 events
| when toggle format | what | by | license | comment | |
|---|---|---|---|---|---|
| Nov 9, 2016 at 8:50 | comment | added | Tsahi Asher | @GregBurghardt DateTime.New is static, and therefore you can't expect it to represent a state of an object. | |
| Nov 9, 2016 at 6:43 | comment | added | user20416 | @GregBurghardt The side effect of a new object might not be an issue in and of itself, because DateTime is a value type, and has no concept of object identity. If I understand correctly, the issue is that it's non-deterministic and returning a new value each time. | |
| Nov 8, 2016 at 19:19 | comment | added | Bradley Thomas | DateTime.Now is regarded as a mistake. See stackoverflow.com/questions/5437972/… | |
| Nov 8, 2016 at 18:06 | comment | added | Greg Burghardt | The DateTime.Now property is commonly used and refers to a new object. I think the name of a property can help remove the ambiguity about whether or not the same object is returned each time. It's all in the name and how it's used. | |
| Nov 8, 2016 at 16:03 | history | answered | Bradley Thomas | CC BY-SA 3.0 |