Dependency injection: Difference between revisions

Content deleted Content added
m de-orphan
Tags: Visual edit Mobile edit Mobile web edit
Line 43:
 
=== Analogy ===
As an analogy, [[car]]s can be thought of as services which perform the useful work of transporting people from one place to another. Car engines can require [[Gasoline|gas]], [[Diesel fuel|diesel]] or [[Electric car|electricity]], but this detail is unimportant to the client—a driver—whopassenger—who only cares if it can get them to their destination.
 
Cars present a uniform interface through their pedals, steering wheels and other controls. As such, which engine they were 'injected' with on the factory line ceases to matter and drivers can switch between any kind of car as needed.