This question already has an answer here:
I have just learned about object initializers and was wondering what the best practices for when to use them are.
This is what I read about them: http://msdn.microsoft.com/en-us/library/vstudio/bb384062.aspx It makes it clear that they are necessary for creating anonymous types but I would like to know if I should try to prefer them to normal constructors in all the other cases.
I believe you are confusing things.
Object initializers will call the default (or a specified) constructor of the class! So you can't really use object initializers instead of the normal constructor. So when using an object initializer you are calling the constructor anyway.
If you are wondering about Object Initializers for a class that you are designing, than the answer still applies. Make sure to provide the necessary constructors that make sense. You don't need to do anything special to enable/allow object initializers. They are syntactic sugar provided by the C# compiler since version 3.0 and allow users of your class to initialize public members of your class, immediately after construction.
A good rule of thumb is:
The main advantage to initializers is that you don't have to set them when the object is created - you can set them later, based on other logic.
I would say no.
Constructors have a huge number of advantages. Using a constructor, the compiler will enforce that all required data is provided to your type. This means you can make it impossible to create an instance of your type that is in an invalid state, which allows you to proactively prevent many bugs.
Object initializers, on the other hand, create many disadvantages. You must provide publically settable properties for any data you need to initialize. They are not required at construction time, so users of your type can accidentally leave out some data.
In general, anything required for your class to function should be required in the constructor. Object initializers can still be used, even if you have a custom constructor, but should only be used for data that's optional in setting on your class. Mixing both in an initialization is fine, which means you can do:
This can help reduce the number of constructor overloads required (similar to using optional arguments, but without some of the disadvantages of versioning in optional arguments).
I currently see the following problems with using them:
So my working theory is: Don't use object initializers they encourage stupid things.