The Art and Science of Software Construction: Clean Code

Any large and complex creative endeavor needs a design.  A movie needs a script and story boards.  A novel needs a theme, a premise and a plot outline.  A work of art needs composition.

Producing software is no different.  Good computer code isn’t just written. It’s designed.  Good code needs a theme, an overall structure and a clear point and purpose, not unlike a good novel or a good movie.

So what makes code good?  The lowest bar code needs to meet is that solves the problem it was written to solve.  That’s like saying a movie has a plot climax.  Just because we’ve cut to the chase doesn’t mean it’s a good movie. Just because the code solves the problem doesn’t mean it’s good code.

That’s where the concept of “clean code” comes in.  A clean design is simple, effective and elegant.  Consider the difference between one of first smart phones—now lost to the dustbin of history—and the first iPhone:

These two products did the same thing.  But one of them had a more elegant design—a cleaner design—and has thus become the most popular smart phone in history, despite its greater cost.

So clean code is effective in that it solves the specified problem.  It’s simple in that it’s easy to understand.  It’s elegant in that all that is in the design of the code is what’s necessary, nothing less, nothing more.  Kind of like the design of the iPhone.  More on this here: Clean Code

Good Trouble on the 4th of July

I have to admit that in the last few weeks, I’ve begun to wonder if this moment in history is similar to the Visigoths having Rome under siege in preparation for sacking it.  In my lifetime I have never lived through any moment like this.  Any one of a pandemic, economic collapse or widespread social unrest would have indicated a disastrous year.  We are experiencing all three.  Is the grand experiment in democracy begun 244 years ago about to end?

It can certainly feel that way.  A nation that is used to leading the world is now leading the world in infections and deaths.  A country that has thought of itself as a melting pot and a gorgeous mosaic is now apparently riven, with the rift between protesters and police enforced with brutal tactics more associated with tyrannies.  Points of science have now become politicized.  

There is one among us who has endured far more than his fair share of the pain.  John Lewis, son of a sharecropper, was regularly beaten by police as he led peaceful protests asserting the right to vote of the historically disenfranchised.

But despite all the suffering he endured at the hands of agents of the government, he did not surrender his hope in the fulfillment of the Founder’s promise.  He didn’t decide to tear down the government.  He joined it.  He is currently serving his 17th term in Congress, representing Georgia’s 5th congressional district.  He hasn’t tried to destroy the democratic system.  He has been trying to fully implement it.  He and others like him have been faithfully trying to complete the experiment and finally realize a government of the people, by the people and for the people—and for all the people.

This nation was born in protest against the unjust and capricious behavior of a monarch.  The facts submitted to a candid world in the Declaration of Independence amount to an assertion of the right of self-determination, a desire to be ruled by a government granted consent by the people and a demand to be governed by a rule of law that recognizes the natural rights and dignity of human beings.  How are these different from what the protesters are asking for today?

This darkest hour of my lifetime may yet turn out to be planting the seeds of America’s finest hour.  Protests cause trouble because they upset the status quo.  Protests are also an act of faith.  For the protesters to believe they will succeed, they must believe in the basic decency and morality of those they are protesting against.  Otherwise, why bother?  If there is no expectation of compassion, there is no point to protesting.  Perhaps out of the many we will finally become one.  Those of us largely unaffected by what has driven our compatriots to the streets are finally listening.  As John Lewis would say, protests cause good trouble.  The rest of us needed to be troubled that citizens of this nation can be arbitrarily deprived not only of their right to vote, but also of their basic right to live.

If John Lewis can still believe in this grand experiment, the rest of us certainly can.   

I wish you all a good Fourth of July.

“We will create the beloved community.  We will redeem the soul of America.  There may be some setbacks, some delays, but as a nation and as a people, we will get there.  And I still believe we shall overcome.”

— John Lewis