Measuring the Goodness of ActionScript 3.0 Design Patterns

Why Design Patterns are Hard
I’m still playing with Skip Lists: A Probabilistic Alternative to Balanced Trees by William Pugh. I have yet to work up an ActionScript 3.0 solution for both inserting new data into a skip list and deleting data from one—even though there’s lots of code that shows how to do it. It’s more fun to look at Pugh’s article with the pseudo-code that he provides to show how to insert/delete data in skip lists. Were I working to figure out a design pattern, I’d be looking at a bunch of association arrows, dashed line instantiation trails and diamond-tailed aggregation spears—just like poor old wound man.
Some of the key parts of Pugh’s article, along with lots of articles you see in professional programming journals have all of these cool formulas. If you’ve seen Flash Math Creativity: 2nd Ed by Keith Peters and some other folks, you’ve seen lots of formulas like the one’s in Pugh’s article although Flash Math Creativity tends to be more trigonometry and geometry than calculus—in any case they’re über cool.
So how do we calculate the efficiency of Design Patterns? The algorithm crowd gets all kinds of cool formulas from every nook and cranny of math—even statistics in some cases. However, in going through The Gang of Four’s Design Patterns, there’s not a single formula that has that kind of proof.
Here’s What I’m Talking About…
In discussing how to work through the cost of running a skip list versus a balanced tree, Pugh offers the following formula:
C(0) = 0
C(k) = (1–p) (cost in situation b) + p (cost in situation c)
which he follows up with:
C(k) = (1–p) (1 + C(k)) + p (1 + C(k–1))
C(k) = 1/p + C(k–1)
C(k) = k/p
Eventualy he comes up with the total expected cost to climb out of a list of n elements as:
≤L(n)/p + 1/(1-p) which is O(log n)
In all of this, C(k) is the the expected cost —length— of a search path that climbs up k levels in an infinite list. So now Pugh can take his formula to the Balanced Tree makers, and say,
See, my formula proves that Skip Lists work as well as Balanced Trees and they take less effort.
So with formulas you can demonstrate mathematically and using math logic that a certain course of action is a reasonable one. So where do we start looking for formulas that can:
- Help determine which pattern to use
- Prove that a design pattern is a better choice over a non-design pattern
Why not start with OOP principles and see if they can help?
Read more…












I’ve been working on a project with Adobe Catalyst, and if I didn’t do something for a Design Pattern tour now, it would be put off until I don’t know when. So I put together a non-design pattern application incorporating video and code snippets from the 



Bill Sanders
Recent Comments