Saturday, October 13, 2018

Fortune's Favor

Two stick figures. One is laboring under the weight of a massive crown. The other is holding the crown up with one hand.

Leonard was not born into a high station. His parents had no money to give him and he had to start from nothing. He was young, strong, and driven, though. So that was just fine with him.

He started as a woodcutter. Every day, he brought back more wood from the forest than he needed and he sold the surplus to old farmers who didn't have the time or strength to collect firewood.

Eventually, he had enough money to invest in better tools and a cart. This allowed him to collect more wood per trip and turn a greater daily profit.

It didn't take long before he had enough demand to hire a second woodcutter. That same demand also ensured he had the capital to invest in tools and a cart for his employee.

After several years, he was supplying firewood and construction lumber to most of his city, which was one of the largest in his country. For his service to industry, the king granted him a barony, which allowed him the privileges of a minor royal.

Then his people were plunged into a long, bitter war with a rival neighbor nation.

Leonard ran toward trouble, rather than away from it. He had trained several lieutenants in his thriving timber business, so he knew the company would be in good hands while he was away.

His minor title permitted him a leadership role but he didn't let that keep him from the front lines. He was true to his name on the battlefield, tearing through the enemy with apparent ease. His men followed suit and his unit gained a reputation among the enemy.

Leonard ascended the ranks with blinding speed. By the end of the war, he was a general, regularly visiting the king's court.

After the war, he was made the king's top military advisor. His business interests had grown in his absence, so he diversified into other endeavors, most of which were successful.

When he ran out of challenges in finance and industry, he turned to the sciences and arts. His contributions to mathematics and physics were minor but still worthy of note. His paintings and carvings were simple but liked by many.

The people rallied on his every word. The king depended on him so heavily, he made him a count.

In their nation, being granted the title of count, rather than born to it, was unheard of but it was technically legal. Because the people so loved Leonard, they cheered at the announcement.

At a private dinner, king Frank confided in Leonard something he'd never told anyone.

"You're a man of honor," said the king, "so I know I can trust you with this. I envy you."

Leonard's eyes "You envy me, your majesty? Surely, you jest."

"No. It's true. You came from nothing, yet here you are. A count, a general, beloved by the people, and one of the wealthiest men in the land." Leonard sighed, then added "You were given a chance to rise and you took it. I may not have done, but we'll never know. I inherited everything I have."

King Frank took a sip of his wine, then added "I'm a man of high birth but you are self-made."

Leonard pursed his lips and thought for a while. "I'm not so sure, your highness."

"Oh?" prodded the king from behind a raised eyebrow. "Will you now reveal your secret royal descent?"

"No," chuckled Leonard. "No, but I do think I've inherited what I have."

"Go on."

"I started as a woodcutter but I was naturally strong. Cutting more than I needed was effortless, so I did it. Selling the surplus and saving the proceeds seemed like common-sense, so I did that, too. I now realize that not everyone could so easily have turned a profit and managing excess income does not come easily to everyone. Those are gifts from somewhere...my parents, God, I won't debate where...but I did not make myself able to do those things.

"Growing a company came easily to me as well. Each thing I did seemed obvious to me but why does everyone not do this? It must be because it isn't obvious to them. More gifts from before I was born.

"War came naturally to me. I was stronger, faster, and more cunning than my enemies. People followed me into battle and, as I rose, tactics and strategy were simple matters for me to assume. Still more things I could do but not for my own effort.

The king shifted in his seat. He seemed to be considering Leonard's words very carefully.

"Business, science, art, mathematics, diplomacy, and matters of state. My proficiency in these things, too, took me almost no time or effort."

"Hmm," said the king. "I'm not convinced. You were strong but you could have spent less time working in the forest and more time reveling in your youth. You were a capable warrior but you could have just kept yourself safe and gone home to your thriving business. You could have been my advisor and put no effort into that business, but you grew it into one of the largest enterprises in our country. You didn't have to contribute to the arts or sciences either, but you did so nonetheless."

"Of course my choices mattered, your majesty, but so did yours. You could have capitulated when we were attacked, but you retaliated. You could have chosen to ignore or not hear bad news, but you wanted honesty from your cabinet. You could have pursued the war all the way to their throne and been saddled with the occupation of a vast and spiteful nation but you graciously accepted their surrender. Now their king swears fealty to you and we receive a yearly tithe of riches and crops.

"...and that's my very point, your highness. What we have - what we all have - is in some regard a function of the circumstances of our birth. We cannot control that but we can control the choices we make after we are born.

"Life isn't fair," added Leonard. "The lives we are given are out of our control. We all have to live with that. What we do with our lives, on the other hand, is entirely up to us...and it's what really matters."

Friday, October 12, 2018

The Final Advice for Suffering Fools

Two people next to one another. One, wearing a jester's cap, shouts "I was parted from my money too soon!" The other, floating above the ground in lotus position and seemingly carried by an halo, says "No you weren't."

I've been writing a little bit about various ways of dealing with people whom you consider to be too foolish to be able to succeed.

I have one last piece of advice on the subject, for now. I guess it's not really like a piece of advice. It's more like a flag in the distance. If you're not there, now, you probably won't be there, tomorrow. You can work toward this goal, if you want to, though.

Like all problems, this one is best solved at the root. Just make it so there are no fools, then you won't have to wrestle with yourself to suffer them.

How do you do that?

I've found the most effective technique is to simply remove "foolishness" from my model of the world. So, for me, there are no fools because there is basically no such thing as a fool.

Maybe it's a bit revisionist, but it works for me.

Thursday, October 11, 2018

For Coupling, Ask "Is There an Hidden Relationship?"

Code: // FRONT TOWARD ENEMY (newline) var cflags = 47 + 4 * Debug.on

Today's code quality question pertains to coupling: "Is there a hidden relationship?"

The most dangerous kind of coupling is that which you don't know is there. If you find yourself writing some code and you can't explain why you're doing what you're doing just by reading the code around it or the tests, you probably have implicit coupling.

So be vigilant. As you write new code, maintain old code, or review others' code, ask the question "Is there a hidden relationship?"

This is a tricky one. You're not going to catch it all the time, at first. That's okay. If you can prevent 10% of the implicit coupling you otherwise would have written or clean up 10% of the implicit coupling you otherwise would have passed by unnoticed, it's a win.

Wednesday, October 10, 2018

For Coupling, Ask "Does This Express a Semantic Relationship?"

There are two kinds of relationships you can form from a class:
  1. The fulfillment of a semantic need.
  2. The exploitation of an implementation detail.
The former kind of relationship is far more resilient than the latter.

There are a lot of reasons why this is true.

The most compelling argument is the asymmetric relationship with change. A change to what you need invalidates an expression of both what to do and how to do it. A change to how something should be done, on the other hand, is unlikely to invalidate what need is being fulfilled.

So today's code quality question is "Does this express a semantic relationship?"

Tuesday, October 9, 2018

The Bizarre Properties of Coupling

Coupling is one of the easiest code qualities to mistake because of its unusual properties.

For one thing, Coupling doesn't require that you have to do the work to find the consequent change but t also doesn't preclude the possibility.

For another, coupling isn't always obvious.

Monday, October 8, 2018

We're More Like Alchemy than Chemistry

An alchemist drops an ingredient into a cauldron, which bursts into wisps of smoke that look like a code snippet (i++) and a UML diagram (one class has an association with another, which depends on yet another)

We like to think we can wear our big-kid pants but our industry is unmistakably in its infancy.

Software development is a not a nascent science. It's not a budding form of engineering. It's not a young profession ready to grow into something big and strong.

We are the precursors to that. We're not doctors, we're shamen. We're not lawyers, we're sophists. We're not chemists, we're alchemists.

Sure, there's nothing magical about how software works. It's not about whether or not magic actually exists. It's about whether or not magical thinking is engaged by a discipline's practitioners.

Besides. Even though the fundamental forces in how software works are pretty well-understood by some, very little is understood about how it is developed among the many.

We're getting better every day, sure, but let's not let a little success go to our heads. Let's be humble and recognize that future moderns will look back on us as primitives.

If we do our very best, our progeny will regard our ideas about how software is made as adorable.

That's okay. Every discipline must go through its formative stage. If you don't need to be right, it can be a thrill to be part of one.

We just need to make sure we question everything and don't take ourselves too seriously.