Richard Bucker

main() is a fractal dimension of semi goodness

Posted at — Apr 28, 2014

Most of the  main() functions I’ve seen and implemented are typically just a few lines long and then immediately launch into the application. On the one-hand it plain to see that the thin layer acts as a way to match the impedance between the application and the underlying operating system. By FD (fractal dimension) one should also be implementing thin layers between the application and any other 3rd party library linked in.On the other hand… if you migrate some code into the  main() function making it thick and actively implements some of the startup then… also by FD you could argue against thin layers between any part of the application and the 3rd party libraries.I like the thin layers. They create the best opportunity to mock the target and write more test cases (IoC and Dependency Injection). Ick!! But then you gotta ask yourself whether or not a thin  main() makes any sense or if the compiler/linker should shorten the dependency.