Welcome to SpellCoder Sign in | Join | Help

Some Cool Stuff in Boo

These are some cool stuff I like about Boo
  1. Duck Typing, that you can treat Boo as a Dynamic Language sometimes if you want
  2. Functions as objects, that you can treat functions as same as objects, passing them like paramerters or return values or whatever without the need of using delegates like C#
  3. Syntactic Attributes
    1. This a good one, you don't need to write setters and getters for your local variables anymore, just specify in an attribute the name of the getter for the specific member variable and the compiler will do it for you,
    2. The [required] attribute before function parameters forces the compiler to generate some defensive code to check the parameters passed to the function if they are null or not, without the need to write this by yourself
juts check this sample code

class Person:
        [getter(FirstName)]
        _fname as string

        [getter(LastName)]
        _lname as string

        def constructor([required] fname, [required] lname):
        _fname = fname
        _lname = lname

it is equivalent to

class Person:
        _fname as string
        _lname as string

        def constructor(fname, lname):
                raise ArgumentNullException("fname") if fname is null
                raise ArgumentNullException("lname") if lname is null
                _fname = fname
                _lname = lname

        FirstName as string:
                get:
                        return _fname

        LastName as string:
                get:
                        return _lname

so this really reduces the ammount of code at least by 10% because actually most of our codes are defensive codes to make sure that no bad parameters are passed to our public API's, also it is great to stop writing the Setters & Getters for all the classes you have because it is very boring even if you generate them,

I really love this language, and I think of creating a plugin for Boo in VS.net 2005 Wink [;)]
Regards
Published Saturday, May 13, 2006 5:10 AM by Mohammed Hossam
Filed Under: ,

Comments

No Comments

Anonymous comments are disabled