/customers/iconara.net/iconara.net/httpd.www/blog/wp-content/plugins/wp-super-cache/wp-cache-phase1.php Iconara » Design patterns & theory

Archive for the 'Design patterns & theory' Category

More on iteration

While iterators (which I covered in my last post) are fantastic, there is more to iteration than that. I’ll cover three common uses for loops and how they can be rewritten in a way that makes your code more reusable and maintainable. Two of the tricks are from the esoteric land of functional programming, and one from Ruby, a cousin of the ActionScript language.

Read the rest of this entry →

On iteration (arrays are Evil)

ActionScript provides a couple of ways to do iteration, for-loops for arrays, for-in-loops for associative arrays and while-loops for the general case. What it doesn’t do is provide us with datastructures that are safe to let client code iterate over, and what’s more, for-loops are so very low-level.

In this article I’m going to make the case why arrays in ActionScript are Evil, give you suggestions on how to use them properly and tell you why iterators are so good.

Read the rest of this entry →

Architectural Atrocities, part 5: Interfaces in AS3

This is the fifth post in the Architectural Atrocities series and now the time has come to scrutinize ActionScript 3.0. The item of discussion is interfaces and how they are used in the ActionScript 3.0 API:s.

Let me start with an OO-maxim:

If you prefix your interfaces with “I”, you have no idea how to use them

Read the rest of this entry →

Higher order messaging

Higher order messaging (HOM) is a concept from the world of dynamic object oriented programming languages like Objective-C and Smalltalk. In this article I’m introducing the concept to ActionScript/JavaScript. It’s quite a theoretical concept, but it’s implementation can be very useful, and because of that, I’ll try to not get too boring.

Higher order messaging is similar to passing functions as arguments to functions, as you can do in ActionScript (but not that many other languages, actually), and it’s this aspect we are going to look further into.

Read the rest of this entry →

Architectural Atrocities, part 3: Side effects

In programming, “side effects” refers to things that happen when you call a function or method, besides the returned value. For example, a method might change the UI, log a message or write to a database, and yet return a value at the same time.

Read the rest of this entry →