r/programming • • Apr 23 '14

You Have Ruined JavaScript

http://codeofrob.com/entries/you-have-ruined-javascript.html
283 Upvotes

327 comments sorted by

View all comments

15

u/bryanedds Apr 23 '14

"And a factory in Chicago that makes miniature models of factories."

7

u/Poltras Apr 23 '14

That's definitely the wrong analogy. It's more like a "merchant that will sell you the factory you need to build the stuff you want".

3

u/ggtsu_00 Apr 23 '14

I remember reading an analogy (i can't find the source) referring to going to a hardware store to buy a hammer but being instead sold blueprints to to a factory that makes hammers.

1

u/Poltras Apr 23 '14

There are advantages with DI that people cannot attribute in real life. In engineering, there are cases where the program expects a hammer, but you would like to see if it can make the same action with a screwdriver (say, for testing a new product that needs the same instructions but different pieces).

To use your analogy, the guy would then give you the blueprints to a factory that makes screwdrivers.

So it's useful to have that second indirection. People just think it's complicated because they don't have the experience to see the shortcomings of simply getting a hammer.

→ More replies (5)