Technology

How the Order of Operations prepared me for Programming

Algebra has always been a favorite subject of mine. There’s not much theory involved, just a toolbox of methods and the order of operations to solve in. If you reach back into high school, you’ll remember (quoted from Math.com):

  1. First do all operations that lie inside parentheses.
  2. Next, do any work with exponents or radicals.
  3. Working from left to right, do all multiplication and division.
  4. Finally, working from left to right, do all addition and subtraction.

Here’s the example from Math.com:
Algebra Example from Math.com

Applying this to development is pretty simple.

  1. Operations within the parenthesis equates to my page layout, in a simple HTML format. I begin with a blank page and steadily populate it until it has all of the elements I’m looking for. To ensure flexible user interface design, I always work with XHTML and CSS. Anywhere where there are expressions (ie. database or programmatic results), I comment the code and type in dummy text, images, or objects.
  2. Next, I work with any exponents or radicals. These are my programmatic or database functions that extracts, transforms, and loads (ETL) the data as I wish to display it in my completed page. I actually work on the steps in that order unless formatting in the actual query results in improved performance.
  3. Next is multiplication or division. This is where I simplify my code. Rather than one huge monolithic script, I abstract as much of the code I can into include files and classes. With web development, I tend to work from top to bottom, of course.
  4. Finally, working from left to right, all addition and subtraction. This step is the final process, applying the last tidbits of form validation, style components, error handling, etc. Again, I tend to work from top to bottom.

Good development is not any more complex than a great Algebra problem. You have variables, equations, functions… and a logical order of operations to get the best results. I see a lot of hackers that simply ‘get it to work’ but you find (as I have) that if you don’t plan out your methodology and take a logical approach, you find yourself writing your code over and over and over when problems or changes are needed.

Algebra has always been a lot like a jigsaw puzzle to me. It’s always been challenging, fun, and I knew a simple answer was possible. All the pieces are there, you just need to find them and put them together correctly. Writing code is no different, but it’s more enjoyable because your puzzle output is whatever you would like it to be!

I’m not a formal developer, nor am I even a great one. I have; however, received compliments on the code I’ve written throughout many projects. I believe much of it is because I do a lot of preplanning, whiteboarding, schema extraction, etc. before I even write that first script tag.

2 Comments

  1. 1

    This was a pretty neat post. I had never thought of applying the order of operations to something as abstract as development, but once you think of it, you see that they’re both abstract in the same way. I’ll have to bookmark this one and use it as a reference. ;]

    • 2

      Thanks Stephen! I’m working on a major project at work right now that spans multiple tables and many pages in a very logical order (all connected by one page utilizing Ajax) and I took notice in how careful I was being and decided to write about it.

      Fun stuff!

Leave a Reply