Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to understand the big picture in a loose coupled application?
    primarykey
    data
    text
    <p>We have been developing code using loose coupling and dependency injection.</p> <p>A lot of "service" style classes have a constructor and one method that implements an interface. Each individual class is very easy to understand in isolation.</p> <p>However, because of the looseness of the coupling, looking at a class tells you nothing about the classes around it or where it fits in the larger picture. </p> <p>It's not easy to jump to collaborators using Eclipse because you have to go via the interfaces. If the interface is <code>Runnable</code>, that is no help in finding which class is actually plugged in. Really it's necessary to go back to the DI container definition and try to figure things out from there.</p> <p>Here's a line of code from a dependency injected service class:-</p> <pre><code> // myExpiryCutoffDateService was injected, Date cutoff = myExpiryCutoffDateService.get(); </code></pre> <p>Coupling here is as loose as can be. The expiry date be implemented literally in any manner.</p> <p>Here's what it might look like in a more coupled application.</p> <pre><code> ExpiryDateService = new ExpiryDateService(); Date cutoff = getCutoffDate( databaseConnection, paymentInstrument ); </code></pre> <p>From the tightly coupled version, I can infer that the cutoff date is somehow determined from the payment instrument using a database connection.</p> <p>I'm finding code of the first style harder to understand than code of the second style.</p> <p>You might argue that when reading this class, I don't <em>need</em> to know how the cutoff date is figured out. That's true, but if I'm narrowing in on a bug or working out where an enhancement needs to slot in, that is useful information to know.</p> <p>Is anyone else experiencing this problem? What solutions have you? Is this just something to adjust to? Are there any tools to allow visualisation of the way classes are wired together? Should I make the classes bigger or more coupled?</p> <p>(Have deliberately left this question container-agnostic as I'm interested in answers for any).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload