Yeah. You can absolutely call that in the constructor as well to make it run once on the entire object. That would be a good approach to do a sanity check before logging. Thanks for the feedback.
For the second approach with bootstrapping, the dependency is still not hidden. Just that we pass it from the bootstrap face. There are some exceptions that might happen with this, so you will need to throw some exception depending on the issue that might occur. The article just focussed on only one exception type but there are others that we can also look at.
I meant hidden as you can create a FileLogger instance without error even if you do not create the file for it, and it will only fail when the first logging takes place, not at creation time.
Yeah. You can absolutely call that in the constructor as well to make it run once on the entire object. That would be a good approach to do a sanity check before logging. Thanks for the feedback.
For the second approach with bootstrapping, the dependency is still not hidden. Just that we pass it from the bootstrap face. There are some exceptions that might happen with this, so you will need to throw some exception depending on the issue that might occur. The article just focussed on only one exception type but there are others that we can also look at.
Great feedback.
Thank you for your answer!
I meant hidden as you can create a FileLogger instance without error even if you do not create the file for it, and it will only fail when the first logging takes place, not at creation time.
Thank you for the explanation. Very much appreciated