Tuesday, May 6, 2014

Reverse domain name qualifiers

When do you specify a "reverse domain name" qualifier in Grails?

Is it only when creating domain classes? Or controllers? Both?
# Which one is correct?
grails create-domain-class Thing1
grails create-domain-class com.mycompany.myapp.Thing1

# Which one is correct?
grails create-controller Thing1
grails create-controller com.mycompany.myapp.Thing1

2 comments:

  1. I think I answered my own question. Kind of. It seems like you can go either way. But you need to be consistent: if you use it for your domain class, you need to also use it for your controller, and vice versa. Grails uses the reverse domain name you specify as the package name (namespace) for your class. Not sure what that buys you in a simple application, though.

    ReplyDelete
    Replies
    1. Yes, it's both. But it's really a "java thing". That's how Java differentiates class names. That way you can have java.util.List (a collection class) and java.awt.List (a UI element), and they are both "List" classes.

      Delete