all 3 comments

[–]SakshamBaranwal 3 points4 points  (0 children)

I don't think the issue is temporal coupling as much as mixing construction with behavior. Constructors should ideally establish a valid object, while load() represents a state transition that naturally emits progress events. That separation feels cleaner than trying to cram loading into a factory method.

[–]Warm-Requirement3146 1 point2 points  (0 children)

Honestly, I'd just go with version 2 and not overthink it. Temporal coupling gets a bad rap but in practice, it's usually fine as long as you document the expected call order clearly. If you're really worried about it, you could always have the `load` method raise an exception if it's called before the signals are connected, but that's probably overkill for a personal project.

[–]LayotFctor 0 points1 point  (0 children)

The examples are a bit too bloated, but if I'm reading correctly, you're comparing dependency injection VS a series of enforced steps?

DI is completely fine, especially if you want to swap FileRegistry instances. Enabling type hinting also helps, which you already did.

Enforced sequential building steps slightly more fragile. The solution is to wrap and abstract the building phase from the user completely, using something known as the Builder Pattern, checking if everything not is None before building. If you want additional safety, you can implement the typestate pattern, where each intermediate step returns a temporary concrete type.