Timeline for Constructor parameter validation in C# - Best practices
Current License: CC BY-SA 2.5
8 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Oct 8, 2015 at 13:20 | comment | added | Ghita | @Ant I wouldn't consider yosefk.com regarding that particular aspect as "state of the art" | |
Feb 25, 2011 at 10:34 | comment | added | Ant | @jk: Hmm, you're right! Though it seems an alternative is to flag bad objects as "zombies", which the STL apparently does in lieu of throwing exceptions: yosefk.com/c++fqa/exceptions.html#fqa-17.2 Objective-C's solution is much tidier. | |
Feb 25, 2011 at 9:53 | comment | added | jk. | eh? throwing an exception from the ctor is the only thing you can do in c++ if you can't construct the object, and there is no reason this has to cause a memory leak (though obviously its up to ). | |
Feb 24, 2011 at 17:25 | comment | added | Eric Lippert | It can still be dangerous to throw exceptions from a ctor in C# because the ctor might have allocated unmanaged resources that will then never be disposed. And the finalizer needs to be written to be defensive against the scenario where an incompletely-constructed object is finalized. But these scenarios are relatively rare. An upcoming article on the C# Dev Center will be covering these scenarios and how to defensively code around them, so watch that space for details. | |
Feb 23, 2011 at 21:10 | history | edited | Ant | CC BY-SA 2.5 |
added 1 characters in body
|
Feb 23, 2011 at 20:21 | comment | added | Ant | Ehh, C++ is a great language, but one of my pet peeves is people who learn one language well and then write like that all the time. C# isn't C++. | |
Feb 23, 2011 at 20:13 | comment | added | ChaosPandion | You are so gonna ruffle some feathers with you C++ comment. :) | |
Feb 23, 2011 at 20:09 | history | answered | Ant | CC BY-SA 2.5 |