Wednesday, May 20, 2015

Code Coherence Is Cool

Some interesting ideas from JOHANNES BRODWALL.

Boiled down a little, he says there are opposing forces in modern code.  Two of these are:

coherence <--> decoupling
reuse <--> decoupling

If you've ever tried to follow the code through a severely decoupled program you didn't write, or wrote a long time ago, you know what losing coherence means.  Instead of just following a couple function calls you get function call -> Spring configuration -> function -> rest service -> Spring configuration -> function -> Hibernate configuration.

In his article Johannes says coherence > decoupling > reuse.  This is not a hard and fast rule but it makes sense.  A program that's coherent can make the difference between a 5 minute fix and an all day goose chase.  I've seen a lot of premature decoupling...when it's unnecessary it just becomes the architecturally correct version of spaghetti code.

Avoiding reuse is awesome, but to avoid reuse you can end up with code that's overly coupled and complicated.

No comments: