Skip to content
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

hw3 dependencies question #30

Open
levbrie opened this issue Feb 19, 2015 · 1 comment
Open

hw3 dependencies question #30

levbrie opened this issue Feb 19, 2015 · 1 comment
Labels

Comments

@levbrie
Copy link
Contributor

levbrie commented Feb 19, 2015

@cz2246 asked:

I am trying to implement the dependencies on other modules and cannot seem to figure out how to get the functions registered in modules a module is dependent on? Where should we store them? Should we store them inside the modules dependent as well?

My response:
@cz2246 Very good question. This is one of the most important issues you have to solve when creating a dependency injection system. There are a few different ways you can handle this, but there are 3 things you have to consider when deciding how to get the functions registered in dependent modules:

  1. Each module specifies its dependent modules at the time it is created.
  2. At the time a module is created, it is not necessarily the case (in fact, it will rarely be the case) that all of the modules it requires as dependents have already registered all of their functions. This means that you can't simply add in all of another modules registered functions at the time you create your module.
  3. Module dependencies may be circular. You need to make sure you can handle circular dependencies (and not loop forever).

In other words, each module needs to have a way to hold on to a reference to all of the modules that it depends on and, if it can't find a function in its registry, it needs to have a way to loop through its dependents until it finds that registered function (or fails to find it).

Make sense?

@levbrie levbrie added the hw3 label Feb 19, 2015
@njt2116
Copy link

njt2116 commented Feb 22, 2015

If anyone else is new to this dependency injection concept, there is a Pluralsight course (albeit slowly paced...) that explains what dependency injection is and what it is doing. For our purposes I think you can watch skip ahead and watch the DI module. Thought I'd share -- here's the link: http://www.pluralsight.com/courses/inversion-of-control.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants