Wednesday, September 05, 2007 3:14 PM szurgot

Programming with Fractal Legos

When I was younger, my uncle had this huge box of legos. When I'd go over to visit, we'd get them out and build with them. He always made these great constructs, planes, and cars and buildings, and the like, whereas I made these ungainly little things, all mismatched colors and assymetrical wings. I think that a good deal of the difference was that they were his, he'd seen the box, and knew what could be done with them, whereas I just had what I could visualize from the myriad pieces of little colored bricks stuffed together in a brown cardboard box.

A few weeks back, I read this article (Bricks) that states that software is not made of bricks. The main thrust of the article is that while some programming metephors compare software development to physical architecture, the reality is somewhat more complex and instead of looking at software as something that can be defined up front with a set number of pieces and construction time where just moving bricks to the construction site can be a help, you have to look at it from a higher viewpoint where the project is more than just the architectural considerations, and the laying of the bricks is the only consideration. The best way I could think to describe it to a co-worker is that if you're going to compare software to brick-building, it would be like having the bricklayer have to stop, and make his own bricks sometimes, and each brick that is made might have to be hand-crafted from different materials.

Of course, the first comment in the article would be a rebuttal comparing programming to legos which states: Usually I started with some idea in my mind of what I wanted to build (a plane, a spaceship, a robot) and then scrubbed the heap of parts looking for the right ones, and slowly assembly them together into bigger ones (always spending a significant amount of time looking for the right piece) until I created something that wasn't what I envisioned originally, but at least could pass for it :-D. Both analogies stuck with me, both felt right, yet something was missing.

Recently I've been doing a lot of programming in WPF, both as a learning exercise, and to apply some new techniques to a five year old program that I never could get right under Windows Forms. Things just "clicked", the code came together, and the new programs are working well. As I was sitting there trying to visualize the process, I had a Numb3rs moment. The end result of programming is very fractal in nature. On the surface, you see a construct (simple or complex, depending on the program) made up of building blocks. As you zoom in on each component, you'll see that it is it's own construct, with it's own building blocks and definition, and so on. You can continuing zooming down until you reach the machine code, and you can go deeper still if you want to change paradigms. And much like viewing a fractal, it may look simple on the surface, but as you delve down, you see the complexity in each piece, a little fuzzy around the edges where it doesn't "quite* resolve, where the line between your code and the APIs blurs.

Nowadays I don't work with Legos, but I do build things that soar. Sometimes it's pretty easy to see which building blocks are in the API, sometimes the line really does blur. And every now and again, there's just no piece to do what you need, and you have to jam in a big Duplo block cause it's the only thing that'll work...

Filed under:

Comments

# re: Programming with Fractal Legos

Wednesday, September 05, 2007 4:03 PM by Munzoor Shaikh

Chris,

It's interesting what you've written here. I work with a Business And Technology Consulting firm called West Monroe Partners. In my group, I started the concept of "Legos", which we've termed reusable pieces of code. Not software, but reusable software code snippets. This was born out of my own frustration of not being able to find my own solution to a specific problem that I had solved sometime in the past. Surprisingly, this idea really took off internally and Legos have become one of the key ways to contribute to our internal group.

Since then, legos have taken off and taken a form of their own. They turn out to be mini-programs with a tutorial-like architectural description. The intent is hardly ever for someone to take the code and plug and play, rather take the code and cut and paste and modify what you need. It's sort of a middle of the road between pseudocode and compiled code. We've found it to help us dig into our "library" of "solved problems" to help us solve problems we haven't solved yet.

Thought I'd share as I enjoyed your view on fractals.

Munzoor Shaikh

# re: Programming with Fractal Legos

Monday, September 10, 2007 5:25 PM by Gabriel C.

Hi,

When I wrote about the lego blocks in my blog, I almost felt silly :) but it was an idea of why I enjoyed programming, and the similarity of it to  my childhood's play with lego. I didn't intend a rebuttal, I wrote it a couple of months before Rangawald's post, but it seemed related to the point discussed.

I agree it has a fractal-like feature, but at some point you end the recursion and you're left with the language/lego basic blocks (is even the same terminology).

Somewhat, the metaphor still looks appropriate to me. Take for example, Domain Specific Languages, is like having fewer but specialized pieces to create different models of a familiy (hmm...Lego Bionicle?) I think Lego has a service where you can draw your model, and they ship the parts to create it... doesn't sounds like MDA?

BTW, Munzoor, quite interesting experience ...