Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialStephen Poole
9,361 PointsIs a dependancy exactly the same thing as a service?
Is a dependancy exactly the same thing as a service?
1 Answer
Chi Lee
3,431 PointsService can be a dependency but dependency is not necessarily or limited to a service.
Dependency injection is a concept. It simply means passing objects to a method/function as parameters instead of instantiate/initialize objects in the method/function. In our case, the object is the service.
The advantage of doing this is the separation of responsibility. It passes the responsibility of initialization to the caller of the method/function. It makes the code more modular and increase maintainability and readability.
Stephen Poole
9,361 PointsStephen Poole
9,361 PointsThank you Chi! Awesome answer, clears it right up!