This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Groovy and the fly likes putting many classes in one file Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "putting many classes in one file" Watch "putting many classes in one file" New topic
Author

putting many classes in one file

Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Groovy experts and authors suggest to have many classes one in a script file for performance reason. This is because groovy parses the entire script file before the code gets executed and classes in the script file are more easily availble than when put in another script file. So we do we organize code - Doesn't script file bloat ?


Groovy
Dierk König
author
Ranch Hand

Joined: Nov 01, 2006
Posts: 43
Originally posted by Prad Dip:
Groovy experts and authors suggest to have many classes one in a script file for performance reason. This is because groovy parses the entire script file before the code gets executed and classes in the script file are more easily availble than when put in another script file. So we do we organize code - Doesn't script file bloat ?


I'm not sure what you mean by "suggest". It is certainly not a general "best practice" and particularly not adviced because of performance considerations.

Could you please link to what expert or author you refer to?

cheers
Dierk
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8903

Sorry If I understood wrongly. Quoting from Groovy in action

In
Groovy, the preferred way is not meshing together numerous script files, but
instead grouping reusable components in classes such as Book. Remember that
such a class remains fully scriptable; you can modify Groovy code, and the
changes are instantly available without further action.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: putting many classes in one file
 
Similar Threads
[Groovy] Ant Scripting
Groovy - another OO script
Getting MethodMissingException on trying to run groovy class
What is Groovy and in which cases we need Groovy?
How to test web application using Groovy