Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@gmethvin
Copy link
Member

No description provided.

@schmitch
Copy link
Contributor

schmitch commented Oct 16, 2016

This is useful especially for testing, where you can manually instantiate components

well as a followup we should probably create some docs around that. we have not much about that topic.
my company actually had a lot of stuff where we created a app and then did app.injector.instanceof while this is not bad, it's way way way way slower than doing new Controller(dependency1, dependency2) ... and manually constructing the dependency chain. (In some cases it's not just seconds, more like minutes..)
Actually google also has Dagger DI where they encourage that pattern.
However it has one bad thing, you can't test the routing. If you don't rely on the reverse router that might be a problem but there is a pattern to just create Controllers that you can fake and then test all routes at once.

@gmethvin gmethvin merged commit 6605e51 into playframework:master Oct 16, 2016
@gmethvin
Copy link
Member Author

@schmitch Definitely. We need to work on better docs for testing before the next release. Especially given that we are removing a few more global things (mainly action builders).

@gmethvin gmethvin deleted the di branch October 16, 2016 18:05
wsargent pushed a commit to wsargent/playframework that referenced this pull request Oct 25, 2016
@mkurz mkurz added this to the 2.5.10 milestone Dec 6, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants