Skip to content

Instantly share code, notes, and snippets.

@mdix
Last active June 12, 2016 11:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mdix/2a5e43f3735f693c48e51ead2cbc4299 to your computer and use it in GitHub Desktop.
Save mdix/2a5e43f3735f693c48e51ead2cbc4299 to your computer and use it in GitHub Desktop.
E-Mail from Chad Parry
That looks great. Sorry it took me forever to take a look at it.
One pedantic thing that I would change is that I would aim for immutability whenever possible.
For example, ApplicationScope.setArgs (https://github.com/mdix/diy-di-typescript/blob/master/class/ApplicationScope.ts#L4)
wouldn't be necessary if instead the ApplicationScope took the args in the constructor.
That way, you are guaranteed that everything is initialized correctly throughout the entire program.
Another pedantic thing I would watch out for is to purge your scope class of any logic.
That includes array access, (https://github.com/mdix/diy-di-typescript/blob/master/class/Injector.ts#L17).
Even though "getArgs()[0]" looks harmless, it's the beginning of an ArgumentParser class, and so that's where that logic usually belongs.
Otherwise, more and more logic will creep in to your scope object.None of that logic will be testable.
On the other hand, keeping the logic in an ArgumentParser class means you can test the corner cases, such as when there are zero arguments provided.
Thanks for showing me the program!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment