Dependency Injection with

batterycopperInternet και Εφαρμογές Web

12 Νοε 2013 (πριν από 3 χρόνια και 9 μήνες)

100 εμφανίσεις

Dependency Injection with
Delphi and the Spring
Framework

Nick Hodges

Gateway Ticketing Systems

Nick Hodges

Gateway Ticketing Systems

What is Dependency Injection?

“…a set of software
design principles
and patterns that
enable us to develop
loosely coupled
code”

--

Mark
Seeman

Coupled Code is really bad.

Uncoupled code is really good.


Making your own cake, or having a bakery deliver it?


What is cleaner for
y
our kitchen?


Law of Demeter


You are at the checkout
counter and buy
something for $25. Do
you:

A.
Give clerk $25

B.
Give clerk your wallet
and let them take out
$25

A house with no plugs?

Rule #1:

Generally

code against
interfaces

The Gang of Four:
Program to an interface, not
an implementation









Rule #2:

Keep constructor logic very simple


If construction of an object is more than straight
assignments, you are doing it wrong.

Rule #3:

Don’t actually ever construct anything


Delegate the task of creation to objects whose specific
job it is to do that.

For Delphi Developers….


Ultimately, coupling is all about uses clauses….


Work to keep uses clause entries to a minimum