There is nothing that says that a constructor of a class can’t perform complex transactions, but most of the people do not expect them to be long running or fragile. When someone is writing a constructor that connects to a database, makes a network call, parses files on disk or something that can error out, that is not intuitive. In the words of Big Lebowski “you are not wrong, you are just an a-hole” My overall mantra of intuitive programming and design is that you should create systems with the principle of least surprise to the caller and maintainer. Most of the programmers assume that object constructors rarely fail and rarely take a long time. Constructors are generally used to create object and assign default or provided values to the fields in the object. The trouble with overloading the constructor with something super heavy is that while you can remember that this is a “special constructor” others won’t intuitively get that. Often times when you do something
Engineering Executive and Advisor, ex DocuSign, ex Microsoft. Passionate about putting together software teams that create award winning products.