0

I have a Java library, quite a huge one.

I'm asking regarding Best Practices of structuring the source.

For example, the logging sybsystem:

Option 1: All in one package, named to sort nicely

  • Log - static accessor
  • LogMonitor - interface for log minotor
  • LogMonitorBase - abstract class
  • LogMonitorStdout - print log to console
  • LogWriter - interface for file logger
  • LogWriterSimple - log writer with just one log file
  • LogWriterArchiving - log writer that handles old log files

Option 2: Subpackages for Monitors and Writers, with better names

  • Log
  • monitors/LogMonitor
  • monitors/BaseMonitor
  • monitors/StdoutMonitor
  • writers/LogWriter
  • writers/SimpleLog
  • writers/ArchivingLog

The second maybe looks better, but perhaps it's not so practical from the java point of view (two extra packages).

What do you suggest as the best practice here? A lot in one package, grouped by naming prefixes, or a lot of subpackages with better names?

4

0

Browse other questions tagged or ask your own question.