Thursday, October 30, 2003

Article On Using Traits On Smalltalk's Collection Classes

If you don't know what traits are, read this excellent article. It's a great introduction to them and provides an example on how (and ultimately why) to use them. Basically, they are an elegant solution to the inheritance problem. I generally tend to favor composition over inheritance, but traits allow you to have your composition with the convience that inheritance gives you. It's amazingly simple and makes perfect sense. Much like most good technology, you don't have to think too hard about it. Go read the article and prepare yourself to say, "WOW!" There is a package on SqueakMap with a simple implementation of traits in Squeak. I also think traits would be pretty easy to implement in JavaScript and Ruby. Yet another reason to pick dynamic languages, they change to you and not the other way around...=)

No comments: