Should the logic in the main class be minimal only by creating instances of other specialized classes and performing all the tasks from there?
Yes. main and its surrounding class should ideally be used only as an entry point for starting a program. The mere existence of a surrounding class is just an artifact of how Java programs stack up (everything should be inside a class), and there is no reason why it should contain other things in addition to the main method (but there is definitely why it should not )
When you get interesting classes (those that make up the actual program) separated, you open the door for all kinds of flexibility. Perhaps some of these classes can be used in some other projects. You might someday want to replace some of them with better implementations. You might find a better order to instantiate all of these classes - so just swap a few lines. Or what about running long boot loads and instances in parallel threads? Just wrap some of them with suitable performers. Good luck trying it out with the main 1000+ class.
Such flexibility matters for everything except, perhaps, for 100-linear elementary examples, prototypes, and the like. But given that even small tools tend to grow, why not do it right from the start?
Joonas pulakka
source share