• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How Groovy should be used with big projects?

 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Means should we write groovy classes first and use them as libraries or we should use them as it is.

I am not clear about the way it should be integrated in the project so that it may not produce any unwanted effects lateron.

Please suggest
 
Dierk König
author
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Himanshu Gupta:
Means should we write groovy classes first and use them as libraries or we should use them as it is.

I am not clear about the way it should be integrated in the project so that it may not produce any unwanted effects lateron.

Please suggest


There is no difference whatsoever between writing a Groovy class or a Java class. With every class you write in your project you are free to choose at any time whether to write it in Groovy or Java. Let me repeat: it makes not difference!

cheers
Dierk
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Dierk K�nig:


There is no difference whatsoever between writing a Groovy class or a Java class. With every class you write in your project you are free to choose at any time whether to write it in Groovy or Java. Let me repeat: it makes not difference!

cheers
Dierk


The ultimate integration happens on the bytecode. That means, only during the compilation (source code level) there would be a different but NOT at the byte code execution level. Right?
 
Pedro Fracarolli
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The ultimate integration happens on the bytecode. That means, only during the compilation (source code level) there would be a different but NOT at the byte code execution level. Right?


Ok, so we can use Java classes in Groovy code. Is the inverse also true? Could I write Java code that uses Groovy classes?
 
Himanshu Gupta
Ranch Hand
Posts: 598
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the great explanation. One more thing I want to get clear is that say for an example in project A groovy is used. So will it be a good choice to mix JAVA and Groovy both in one class. Wont it become difficult for the other person to understand as he has to figure it out that which code uses groovy and which code uses JAVA.
 
Marc Peabody
pie sneak
Sheriff
Posts: 4727
Mac Ruby VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Pedro Fracarolli:
Ok, so we can use Java classes in Groovy code. Is the inverse also true? Could I write Java code that uses Groovy classes?

Yes you can.

I think it's often best to static type the return values of the Groovy methods you plan on calling from Java. Actually, I prefer to do so on most Groovy methods anyway.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Himanshu Gupta:
Wont it become difficult for the other person to understand as he has to figure it out that which code uses groovy and which code uses JAVA.


As there IS a difference in syntax, I don't think it would be that difficult. It would be like a difference between the Javascript code Vs Java code in a JSP page!
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Marc Peabody:

Yes you can.

I think it's often best to static type the return values of the Groovy methods you plan on calling from Java. Actually, I prefer to do so on most Groovy methods anyway.


What exactly the "static type the return values" mean here Marc? Can you please throw some lights on this?
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Raghavan Muthu:


What exactly the "static type the return values" mean here Marc? Can you please throw some lights on this?


In groovy you can define methods without specifying return types. I guess Marc is suggesting to explicitly specify the return type.
 
Raghavan Muthu
Ranch Hand
Posts: 3381
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Prad Dip
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic