Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Which is a better practise and why?

 
kshitij kaushik
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
which is a better practice and why? Writing whole source code in a single java file or writing individual java files for each class or mix of both.....
please answer.....
 
Sagar Rohankar
Ranch Hand
Posts: 2906
1
Java Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SUN recommends "class per file", For more details, look here !
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
kshitij kaushik wrote:whole source code in a single java file


Dear kshitij , what do you mean ?
 
Rob Spoor
Sheriff
Pie
Posts: 20495
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think he means this:

All in the same file, with at most one of the classes public.


Except for little test cases, I would really discourage this approach. With each class in its own file, there is a better overview of where you can find each class. If everything is in one file you have to do a search first.
 
kshitij kaushik
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
okey.....Thanks a lot guys for giving your precious time for my query.....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic