|
|
|
|
|
by eru
3999 days ago
|
|
Yes, that's what I was playing at. Other languages have things similar to design patterns, too. If you are in luck, a language gives you first class support for abstracting new patterns. (Eg in assembly a procedure is just a pattern and convention, most modern languages help you by providing procedures. Same languages are very good at being extended. Lisp is a good example, and so is Haskell. Even Python is great in that respect compared to, say, Pascal.) I am still trying to figure out what dependency injection really is. It's seems like only the Java guys have a need for it, but they rave about it. |
|
foo() { service = someRemoteService(authn, authz); http://lookingglass.internal.adm.bol.com/?page=TAM+Middlewar... }
is replaced by
foo(service) { do_something_with_service(service) }
It makes replacing service with fake_service_object easier, thus simplifying the test process.
Common use case: If your service was a remote database, you can replace the database handle with a mock object which pretends to be a DB but is actually a simple object returning hardcoded values.