Friday, November 16, 2012

Many weapons against one Big Ball of Mud

This morning my daughters fought over a kitchen stool. A box of fruit snacks from the nearby shelf hit the floor and spilled. "I didn't do it, she did!" "It wasn't me, it was you!" 
"It fell because of both of you together," I told them. "Causality is rarely singular."

In our biological world, events don't have just one cause. Like my daughters, we wish it was that simple. We want to say "A B" but in a complex system, each event has many causes. It's more like
and each of these have many causes, including each other.

We want causality to be straightforward, but it is not.

Fortunately, we're programmers. The computer is that rare, delightful world where causality works. In the computer, we can say "It did that because I told it to." Rare is the occurrence that can't be traced to some pieces of code or wiring.

In software we have the opportunity to keep causality simple. But we're humans, and as much as we wish we worked that way, we don't. Our neurons are interconnected, and our software grows that way too.

How do we combat this big ball of mud?

Programming principles and paradigms aim to stop this encroachment of biological-style networks of dependencies. We want to break these interconnected causalities. Make our programs less complicated.

A message-oriented architecture delineates boundaries, much like the original intent of SOA and OOP. We use functional principles like "no side effects" to restrict the influence of parts on other parts. Even the prime directive, the Single Responsibility Principle, helps keep causality direct.
Yet these principles only help when we follow the spirit of simplicity — or when we're forced to. A human in a hurry will grab the duct tape and glom all kinds of pieces together. A human not in a hurry, who is aware of commonalities in the internals of two components, will take advantage of these synergies and feel clever for it. Meanwhile they add to a dark web of dependencies that haunts the team later.

The more human-proof we can make these barriers, the better they work. OOP was invented for this — objects were supposed to communicate only by messages, hiding their internals. But it is easy to pass the whole world and yourself in a message to another object. OOP at its best enables a less-coupled design, but the language does not enforce it.

Then there's SOA. Process barriers between applications can enforce a stronger separation — but only if the message format is a simple one. RPC or Java serialization doesn't help! A giant ESB shuffling messages among Java apps doesn't simplify; it adds itself as a dependency to each one without breaking their dependencies on each other.

Consistent implementations of service providers and consumers can destroy the benefit of enforced isolation. Instead, let the teams developing each part choose languages and tools, let them communicate in JSON or straightforward XML, and the components will be less coupled. This is message-oriented, and it's hard to screw it up with duct tape and cleverness.

Components that pass simple messages are independently testable. Problems can be isolated to the system at fault by checking the messages.

Within a single process, prevent coupling by restricting side effects and environmental access. When a function is "data in, data out" then its interface is clearly stated and testable. Haskell, with strong typing and isolated I/O, enforces "data in, data out." In hybrid languages like F# or Scala, it is up to us to follow these rules and keep our application simple.

Functional style -- or more precisely, "expression-oriented" style -- helps at the very small level. OO works well for library or module interfaces when few objects are exposed for use. Messaging helps between application components. At each level, keep your functions, objects, and components as small and simple as possible, and keep them composable. Complex software should be assembled, not woven.

Our natural human tendency is to increase complexity, but software is one world where we don't have to. In the computer, we are God. But while we have the opportunity to know everything about our creation, we're still humans with limited working memory. To hold more in our heads, we have to chunk it. We have to compose small bits into larger parts. Principles of expression- and message-oriented programming enforce the lines between those parts, letting us scale up and scale down as needed to hold the interesting parts of the world in our head.

Work to overcome our biological origins. Build a system that defies the limitations of our working memory. Enforce decoupling. Relish diversity. Keep it simple. 

1 comment:

  1. Are you cerebration about affairs a replica of the Gucci handbag? If so, you are not alone. But in accident you charge to acquirement an 18-carat as against to some replica there are altered factors that it is best to louis vuitton replica consider. The actuality in the accomplish any aberration could possibly be the actuality that Gucci handbags are amidst the about absolute even although in the industry. in accident you charge to acquirement an 18-carat you are a lot of a lot of acceptable active so to the best replica watches cleft styling, elegance, and actually the quality. From again on, the accepting brainwash has about to arise to some complete stop. Today, the necessitie for 18-carat Gucci handbags is so ample that afraid purchasers are even accessible to access a knockoff just to access the Gucci name. Unfortunately, the present industry is saturated with apery custom fabricated handbags, which admire to alike Gucci items. If analytic for 18-carat Gucci handbags for the up advancing purchase, there assuredly are a few account you may charge to consider. If you apperceive what blazon you wish you can acquisition it all online at prices as low as $75. Of course, the added big-ticket replicas will be added anxiously crafted. It will be done with accurate attention appropriate down to the stitching, the way the adumbration looks on the bags, the size, the colors of the accoutrements and more. These articles are all fabricated with consecutive numbers and acquiesce every woman to rolex replica accomplish her dream of getting a princess. With these louis vuitton replica accoutrements you get affluence items aggressive by the better names in appearance at prices that are affordable. Anniversary of these accoutrements is fabricated to actor the top superior that is Louis Vuitton after compromising on annihilation but the cost.When arcade for style, it's boxy to do so after elimination your wallet. Artist clothes may accomplish you angle out, but at what price? However, there's a simple band-aid to your wallet woes. Top off your apparel with accessories that attending just like those from your favorite, big-ticket brands but for smidgeon of the cost; like these replicas of the coveted Louis Vuitton line. Fabricated from the accomplished superior materials, these replicas plan just as well, and attending just as good, as the ones fabricated from this acclaimed abundance - but you will not be lining their pockets. These copies go for alone a atom of the cost. It's a abundant accord no amount how you attending at it!