When I first started programming, I wrote everything in main. But as I learned, I tried to do as little as possible in my main()
methods.
But where do you decide to give the other Class/Method the responsibility to take over the program from main()
? How do you do it?
I've seen many ways of doing it, like this:
class Main
{
public static void main(String[] args)
{
new Main();
}
}
and some like:
class Main {
public static void main(String[] args) {
GetOpt.parse(args);
// Decide what to do based on the arguments passed
Database.initialize();
MyAwesomeLogicManager.initialize();
// And main waits for all others to end or shutdown signal to kill all threads.
}
}
What should and should not be done in main()
? Or are there no silver bullets?
Thanks for the time!