Good or bad practice? Initializing objects in getter
问题 I have a strange habit it seems... according to my co-worker at least. We've been working on a small project together. The way I wrote the classes is (simplified example): [Serializable()] public class Foo { public Foo() { } private Bar _bar; public Bar Bar { get { if (_bar == null) _bar = new Bar(); return _bar; } set { _bar = value; } } } So, basically, I only initialize any field when a getter is called and the field is still null. I figured this would reduce overload by not initializing