File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Groovy and the fly likes Code to Interface in Groovy Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Code to Interface in Groovy" Watch "Code to Interface in Groovy" New topic

Code to Interface in Groovy

Freddy Wong
Ranch Hand

Joined: Sep 11, 2006
Posts: 959


I'm starting to learn Groovy and I like it. I'm just wondering if in Groovy it's still a good practice to code to interface since we can rely on the duck-typing? I know we still can have interfaces in Groovy, but I'm trying to code like a Groovy developer and not a Java developer


SCJP 5.0, SCWCD 1.4, SCBCD 1.3, SCDJWS 1.4
My Blog
Marc Peabody
pie sneak

Joined: Feb 05, 2003
Posts: 4727

The "best practice" of "code to the interface" doesn't even necessarily mean you'd create any interface types, even in Java.

From experience, I don't think it makes sense to create actual interface types in Groovy. I even avoid doing so in Java unless absolutely necessary.

A good workman is known by his tools.
I agree. Here's the link:
subject: Code to Interface in Groovy
It's not a secret anymore!