This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Groovy and the fly likes How Groovy should be used with big projects? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "How Groovy should be used with big projects?" Watch "How Groovy should be used with big projects?" New topic
Author

How Groovy should be used with big projects?

Himanshu Gupta
Ranch Hand

Joined: Aug 18, 2008
Posts: 598

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


My Blog SCJP 5 SCWCD 5
Dierk König
author
Ranch Hand

Joined: Nov 01, 2006
Posts: 43
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

Joined: Apr 20, 2006
Posts: 3344

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?


Everything has got its own deadline including one's EGO!
[CodeBarn] [Java Concepts-easily] [Corey's articles] [SCJP-SUN] [Servlet Examples] [Java Beginners FAQ] [Sun-Java Tutorials] [Java Coding Guidelines]
Pedro Fracarolli
Greenhorn

Joined: Sep 03, 2008
Posts: 20
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

Joined: Aug 18, 2008
Posts: 598

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

Joined: Feb 05, 2003
Posts: 4727

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.


A good workman is known by his tools.
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

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

Joined: Apr 20, 2006
Posts: 3344

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

Joined: Feb 27, 2002
Posts: 8904

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.


Groovy
Raghavan Muthu
Ranch Hand

Joined: Apr 20, 2006
Posts: 3344

Thank you Prad Dip
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How Groovy should be used with big projects?
 
Similar Threads
Groovy vs JavaFX
What is Groovy and in which cases we need Groovy?
Software Factories / MPS
Packaging and Documentation
does groovy require a different framework?