• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Tim Cooke
  • Liutauras Vilda
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • fred rosenberger
  • salvin francis
Bartenders:
  • Piet Souris
  • Frits Walraven
  • Carey Brown

Inner class or not

 
Ranch Hand
Posts: 161
Firefox Browser Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When coding, how do people make a decision on making a new file, placing classes on one file, or making it a private static attribute of a class.

To be specific, I am working on SortNames class and I created a class that implements a generic. I thought this class is small enough not create a new file, and others classes might use this capability so I decided to make the class within a file. How do others make their decision?
 
Trailboss
Posts: 23216
IntelliJ IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you start to speculate about how you might use something in the future, you have just touched a tar baby that you could become entangled in for all time.

Focus.

Do the bare minimum to meet the needs of the assignment.

80% of all developers fall into the "what if" trap. I want you guys to stay the hell out of it.

 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To make the source of a class easy to find, give it a seperate file.

To make it hard to use, put it inside another class.

If I want to show a small, working example of something in a forum, to ask or answer a question, I try to put it into a single file, so it's easy to copy that whole bunch of stuff, put it into a file, compile and see for your own what it does / an error.

    Bookmark Topic Watch Topic
  • New Topic