Startup of more complex c++ applications is a problem. As an application developer you often don't have the ability to fix a lot of the issues related to this problem but there's one thing that bothers me a lot, that you, as an application developer can fix, so I decided to write about it a little today. I'll talk a bit about "delayed initialization" today.
KCmdLineArgs *args = KCmdLineArgs:: parsedArgs();
MainWindow *window = new MainWindow( args );
a.setMainWidget( window );
This in turn means that before we get at all to the event loop of the application the main object has too be fully constructed. That in turn implies that we want to avoid doing any non-trivial task in the top-level constructor.
So what should you do? It's very simple: delay the construction of anything besides the GUI until the event loop starts. For example here's how our simple MainWindow should look like:
Now what this means for users? It means that they will see the GUI for an application almost immediately. The fact that the app isn't yet functional when the GUI shows up doesn't really mean anything, because once you're in the event loop you can let users know you're not ready by either disabling the widgets of showing a progress bar while the app initializes. In most cases neither one will be even necessary as no one will start clicking right away on the app when it shows up. But it will have the cool effect of making your application seem a _lot_ faster even though you haven't done any real code optimizations :)