• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Code to Interface in Groovy

 
Freddy Wong
Ranch Hand
Posts: 959
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

Thanks.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic