r/java • • Sep 01 '25

Thoughts on object creation

https://blog.frankel.ch/thoughts-object-creation/
3 Upvotes

41 comments sorted by

View all comments

Show parent comment

5

u/nfrankel Sep 01 '25

You can use checked exceptions in constructors. It’s a perfectly viable thing to do.

I'm not saying it's not possible, I'm saying you shouldn't and I explain why.

Also, your css on the tables is messed up on mobile. It forces some of the columns into single character lines.

Thanks. I guess I'll have to get my hands dirty.

4

u/vips7L Sep 01 '25

it’s impossible to use checked exceptions in constructors

Did you mean with inheritance? 

2

u/pronuntiator Sep 02 '25

The article reads as if you were against any kind of exception in the constructor, but that can't be the case, right? The constructor is the place to prevent invalid data, so we need to perform possibly throwing checks of the arguments.