The purpose of the constructor is to instantiate the class.
Problem with database query - operation may fail.
At this point, if you handle the exception incorrectly, your code is a candidate for errors.
You should think of a constructor to prepare an object for use, which should be fast.
source
share