oop - How to understand the big picture in a loose coupled application? -



oop - How to understand the big picture in a loose coupled application? -

we have been developing code using loose coupling , dependency injection.

a lot of "service" style classes have constructor , 1 method implements interface. each individual class easy understand in isolation.

however, because of looseness of coupling, looking @ class tells nil classes around or fits in larger picture.

it's not easy jump collaborators using eclipse because have go via interfaces. if interface runnable, no help in finding class plugged in. it's necessary go di container definition , seek figure things out there.

here's line of code dependency injected service class:-

// myexpirycutoffdateservice injected, date cutoff = myexpirycutoffdateservice.get();

coupling here loose can be. expiry date implemented literally in manner.

here's might in more coupled application.

expirydateservice = new expirydateservice(); date cutoff = getcutoffdate( databaseconnection, paymentinstrument );

from tightly coupled version, can infer cutoff date somehow determined payment instrument using database connection.

i'm finding code of first style harder understand code of sec style.

you might argue when reading class, don't need know how cutoff date figured out. that's true, if i'm narrowing in on bug or working out enhancement needs slot in, useful info know.

is else experiencing problem? solutions have you? adjust to? there tools allow visualisation of way classes wired together? should create classes bigger or more coupled?

(have deliberately left question container-agnostic i'm interested in answers any).

while don't know how reply question in single paragraph, attempted reply in blog post instead: http://blog.ploeh.dk/2012/02/02/loosecouplingandthebigpicture.aspx

to summarize, find of import points are:

understanding loosely coupled code base of operations requires different mindset. while it's harder 'jump collaborators' should more or less irrelevant. loose coupling understanding part without understanding whole. should need understand @ same time. when zeroing in on bug, should rely on stack traces rather static construction of code in order larn collaborators. it's responsibility of developers writing code create sure it's easy understand - it's not responsibility of developer reading code.

oop language-agnostic dependency-injection loose-coupling

Comments

Popular posts from this blog

How do I check if an insert was successful with MySQLdb in Python? -

delphi - blogger via idHTTP : error 400 bad request -

postgresql - ERROR: operator is not unique: unknown + unknown -