wood burning stoves 2.0*
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
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: 8919

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: 8919

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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: putting many classes in one file