Remix.run Logo
▲ zubspace an hour ago

This is something I struggle with alot.

Constructors make alot of sense to me. It's a promise to the caller that the instance is fully initialized after it returns.

But there are cases where it simply ain't possible. For exampIe I always struggle with object pools, where you construct a bare instance and reuse it later on. In such cases it is often very cumbersome to to guarantee that each instance is properly initialized and uninitialized in every case. It gets worse when different instances are involved, depending on each other. The more classes there are, the worse it gets.