-
Notifications
You must be signed in to change notification settings - Fork 261
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
Circular Referencies (Dependencies) #139
Comments
Hmmm.... circular dependencies should really be avoided as a best practice. I don't know whether it's actually a good idea to try and support them. |
You are wrong. One of the main concepts of IoC is to avoid of dependency hell and helps to rule-em-all:) class ConcreteMediatorHelper {
[Inject] public var mediator : SomeMediator;
override public function help() {
mediator.showHelpScreen();
}
}
class SomeMediator extends Mediator {
[Inject] public var concreteMediatorHelper : ConcreteMediatorHelper;
public function doSomeStuff() {
concreteMediatorHelper.help();
} this is a simplified example of issue in our project. And it really should be fixed, just look in Java Spring IoC, there are cyclic references support from the begining AFAIK. |
That doesn't mean it's good practice though. Circular dependencies are a serious code smell, and IMO we shouldn't be encouraging bad habits. I can only imagine benefits for circular dependencies in data structures, but never for actual components. And in the case of data structures it's the responsibility of the structure itself (or its composer) to fullfil and maintain the dependencies. |
I do realize it's a pure SwiftSuspenders issue, but since Robotlegs v2 is about to be released and SwiftSuspenders is some sense the base of RL and RL is definitely more popular project out of two...
It seems like SwiftSuspenders still can't handle circular referencies as mentioned before here tschneidereit/SwiftSuspenders#11.
I tried with this commit https://github.com/tschneidereit/SwiftSuspenders/tree/4205e4e4376f6769834399bc8159dfa62d04860e, the test code look as follows:
Output is:
with a following stack overflow.
The text was updated successfully, but these errors were encountered: