I have been developing in Groovy for a little while now and I'm wondering how often I should be using the dynamic casting def
? A co-worker of mine believes we should use it always as it helps Groovy in some way I don't understand.
Currently, when declaring method return types and arguments, I like to deliberately state which objects should be taken in and spit out (for code readability and I come from a Java background it makes sense to me) example:
String doSomething(String something){
//code
}
// vs
def doSomething(def somthing){
//code
}
// vs
def doSomething(somthing){
// code
}
So I guess my question is it just a preference of when to use def
or is there a real advantage to using it all the time? (I added the last example because I felt it fits in with the question as a viable option for Groovy)