Journal of a software dev

June 18, 2008

Power of Boo

Filed under: boo — Tags: , , — Michael Cromwell @ 8:11 pm

After spending some time looking at examples of the meta programming Boo supports by having an open compiler it got me thinking how you could effectively generate boilerplate code for a class by just decorating it with an attribute, the example I was thinking of was of the standard singleton design pattern, the general setup for a singleton object involves:

  • having a private constructor
  • having a single static instance variable holding the type of the singleton
  • exposing an static instance property/method that returns the instance variable
  • possibly thread locking code if it will be used in a multi-threading environment

Now with Boo you can use an inherited attribute class of the AbstractAstAttribute to make adjustments to classes, fields, methods etc…

And just as I was thinking you could have a SingletonAttribute to perform the above standard tasks I came across this https://docs.codehaus.org/display/BOO/Useful+things+about+Boo someone has already implemented it!

I’m starting to really appreciate how powerful this language is :-)

No Comments Yet »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a comment

Blog at WordPress.com.