-
Notifications
You must be signed in to change notification settings - Fork 268
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Initializer circular dependencies - support or not? #161
Comments
I think moving RaiseCircularInit into TyphoonCallStack is not good idea, because it used here: [[_stack peekForKey:componentKey] addInstanceCompleteBlock:^(id reference)
{
[(NSObject*) instance setValue:reference forKey:propertyName];
}]; That means if we init first object with second as init parameter, and second references to first with property, second will wait until first end initialization and then point to first by property. |
Fixed by adding |
Perhaps its a little bit too surprising to have the two methods with different types of behavior? I had it like this: peekForKey:(NSString*)key raiseCircularDependenciesException:(BOOL)raise . . but was toying with the idea that maybe we don't need that parameter. I started moving some things out of TCF+InstanceBuilder (was becoming a god-class). . definitely seemed to work for the init invocation - allows using polymorphism by assigning the responsibility of argument setting to the parameters. . . . I thought it made sense for TyphoonCallStack to take on this responsibility. Perhaps not? |
Yes, I agree that TyphoonCallStack is place for exception. I just want to say that we have to support this circular dependence. It is not hard (or a lot of code) to support. I can't imagine example of usage, but If user can imagine it, he will be surprised that it is not supported. |
I think better to raise exception in TyphoonStackElement instance getter. I.e. when someone access to instance while it in initializing state -raise exception |
@jasperblues check current implementation, may be it is better |
Looks g |
Looks good Aleksey :) |
So, we're moving towards raising an exception for circular dependencies in initializers?
I was moving the RaiseCircularInit exception concern over to TyphoonCallStack (better OO and I want to reduce complexity in TCF+InstanceBuilder). .
In doing so, I found a new case that wasn't being detected as yet:
thoughts?
As we always try to check in green builds, i've changed the test conditions, but we need to decide what to do here. support or not.
The text was updated successfully, but these errors were encountered: