Aspect Oriented Manager of Morale Works! JavaOne to be SunOne again?
Mar 02

Groovy Beans: properties, and named parameters

Groovy, Tech Add comments

Cedric talks about his desire to have real properties in Java, and points to Groovy’s Plain Old Groovy Objects which gives us the syntactical sugar.

I definitely agree with him, and also really like the named parameters that you see in the Groovy examples:

import java.util.Date class Customer { // properties Integer id String name Date dob // sample code static void main(args) { customer = new Customer(id:1, name:"Gromit", dob:new Date()) println("Hello ${customer.name}") } }

I have always liked named parameters, as I have seen many bugs due to methods such as: doFoo(String acct1, String acct2). Here we have no way to know if someone is passing in the right info (other than via Unit tests).

This comes up a lot more when you use primitives as arguments, and some people try to get around the problem by always using encapsulated representations… but that just doesn’t work all the time, and is an overuse of OO.

Groovy is just looking nicer and nicer.

Groovy Beans page

9 Responses to “Groovy Beans: properties, and named parameters”

  1. Otaku, Cedric's weblog Says:

    Named parameters

    Dion likes named parameters: I have always liked named parameters, as I have seen many bugs due to methods such as: doFoo(String acct1, String acct2). Here we have no way…

  2. Tom Says:

    Unfortunately this only works for constructors, real named parameters are not possible since Java does not save parameter names in class files.

    Sigh.

  3. Gabriel Ford Says:

    Great post! I’m looking forward for more. when Grass Rape Slot Percieve: http://movies.yahoo.com/ , Big Slot Win or not Boy will Chips unconditionally , Gnome can Loose Cosmos when Grass Love Gnome Kill

  4. iclal ışıl Says:

    travestii.com toplu travesti sitesi

  5. iclal ışıl Says:

    travestii.com toplu travesti sitesi

  6. iclal isil Says:

    travestii.com toplu travesti sitesi

  7. iclal isil Says:

    birbirinden guzel travesti sitesi travesti iclal travestiler burda turkrktravesti siteleri bir arada

  8. Anonymous Says:

    birbirinden guzel travesti sitesi travesti iclal travestiler burda turkrktravesti siteleri bir arada

  9. iclal Says:

    birbirinden guzel travesti sitesi travesti iclal travestiler burda turkrktravesti siteleri bir arada

Leave a Reply

Spam is a pain, I am sorry to have to do this to you, but can you answer the question below?

Q: What are the first four letters in the word British?