Browsing the blog archives for February, 2013.

Music as a Metaphor

work safe

Music is a highly structured art form… usually. This structure makes use of repetition and variation of form. Music can be monophonic or polyphonic, one voice or many voices interacting with each other. That’s what makes it interesting as a way of exploring code structure.


A Symphony is a collection of songs, called movements, connected in some manner. They share a collection of themes and other musical ideas. But each song operates in its own reality.   Each song has its own musical key, tempo, and time signature giving each movement a very different feel. Each song still serves to bolster the Symphony as a whole.

Some applications have such different responsibilities we express each responsibility as a different executable program. A time sheet software may have a time entry client, a time entry server, time code management, a reporting system, and a payroll system. The themes that string everything together are the Ubiquitous Language and shared data interfaces. Each program has a shared understanding, but can act on that understanding in the manner that best fits its unique responsibilities to the application as a whole. In addition, some programs/services may serve to alter the data from one format to another, such as waiting until generating invoices to transform from a format used by most of the application to the format needed by our third party software.

Verse-Chorus Form

Your basic pop song has an internal structure called Verse-Chorus form.  The verses have similarities to their internal structure but vary differently in the content. The variance is usually the words of the verse. The chorus is the same, used to break up the verses.

We can see Verse-Chorus form in an app with several data screens, like the time entry client.  Each screen is a Verse stitched together with both a data layer and navigation framework, the Chorus.

On occasion, a song has a radical change called the Bridge. This can alter the musical key as well as rhythmic underpinnings and has little similarity to the rest of the Verse-Chorus form but serves to add interest before returning to the original structure. As our time client grows, we find reports and off-line syncing that are important to our application, but are structurally very different from itself.


A Canon is a way of manipulating a melody. The simplest example would be Row Row Row Your Boat, where the melody is time shifted by one third. When this happens twice, for a total of three instances, we get a special class of canon called a Round and can repeat the layered melody Ad infinitum.

In our time application, we can think of the canon as the series of transformations we need to apply to our employees’ time data this billing period.  We collect, group, transform, and collect again.  In C# this can be a rather long list of Linq operations.  In SQL, a very complex query.  But a lot of the data accumulation and transformation can be carefully done in parallel.  Much like a canon.

Why Care?

This is an incomplete metaphor. I wouldn’t use it as a means of laying out your code base. Instead, I can see it used to seed discussion about similarities and structure. By understanding that parts of your application have similarities and differences, the hope is we can group our code in a way that helps separate responsibilities, give clarity, and let developers quickly find the code they need.

No Comments

Programming is Math?

work safe

This sculpture is known by some students as the Cecil T. Lobo Whatzit. This sculpture was installed on the Rose-Hulman campus by the Civil Engineering Department as an example of 17 different the steel joints. It is an amazing technical challenge to find harmony and balance with in the constraints of 17 steel girder joints, all “Golden-Gate Red”.

Quite frankly it looks like junk to my untrained eye.

I had a conversation one morning where we were talking about art for the sake of art. We talked about collaborations and other art projects that are interesting to those steeped in the art form, but not to the uninitiated.

One phrase I keep hearing stated as a universal truth is “Programming is Math.” I’ve tried to ask people what they mean by this, but I have yet to find someone who doesn’t think I’m trolling them. The problem is EVERYTHING is Math. Economics is Math. Engineering is Math. Architecture is Math. Even Painting is Math.

But everything is also Poetry. Ask a Poet.

I was trained as an Engineer. Capital E. I took classes on fluid dynamics, forces on static structures, and circuit design. I see the world as a list of Knowns specific to a problem, a bunch of Given universal truths and equations, and a solution I’m attempting to Find. Elegance never entered in to that much. But then I began seeing how solutions work for real people, how they impact their lives. Defining the problem became much more interesting. Math was only something I used to get there. In programming that was usually Algebra, Boolean Logic, and Trigonometry.

Okay, lets get back to software. There are a bunch of techniques we use when architecting software. There are books and books of patterns on the subject. We try to find a pattern to match the entire solution, but we will fail. That’s not to say we shouldn’t understand these techniques and explore them, just that we shouldn’t confuse a study with art just because it is well done.

The problem I have with this is first and foremost, it is seen as an obvious truth that needs to be stated, but once stated is self evident. When making such a statement, you should be offering help on the road to enlightenment, not merely shouting from the mountain top that you have achieved satori. It annoys me that I’ve yet to find a way in to this secret understanding of Math having always been horrible at wrote computation we teach kids in American Math classes. But it also feels counter to what I have come to understand about software in my 13 years as a professional practitioner.

“The Second Law of Consulting: No matter how it looks at first, it’s always a people problem.” – Gerald Weinberg

The things that make my life difficult aren’t a lack of technical choices, but understanding the implications of how those choices fit together. Especially if I wasn’t there to participate in the evolution of thought and circumstance.

The thinking of Programming as Math feels like we are suborning the technique to the expression. The art is getting lost in the technical aspects of the art form. I want to say communication and clarity to my fellow developers and collaborators is far more important than technical details of my solution. There are techniques that help me do that, but only if they serve the communication.

And I still can’t see where programming like this is Math as I understand it.

No Comments