Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

It's slightly more.

Your code wouldn't create it's own ShippingGateway - it would be passed in (or "injected"). That Shipping Gateway could be a RealShippingGateway (for when the application is running in production) or a MockShippingGateway (for unit testing), or some other variant for when your test users don't want to actually ship things. It doesn't matter which of those it is to the object it's passed into, all it knows is that it has a ShippingGateway, and when/how to call it.

So it's Adapter Pattern + Interfaces together that matter.



Makes sense. So basically this is DI for adapters/gateways?


That's my understanding. But I'm not 100% I haven't missed some subtlety.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: