Parent Child

Previously our project had a main application with a lot of code. It allowed the user to do all kinds of queries, among other things. The application was getting unwieldy. So my team lead thought it would be good to distribute some new functionality in separate applications. However any new applications needed to integrate with the main app. Therefore I took on a task to split out some of the existing functionality from the application to a new stand alone application. The goal was to leave the user experience the same, while prototyping ways to interface with the main application. I decided to choose of the many queries to split out.

Some of the challenges with integrating the stand alone and main applications included dealing with cached data in the main application. However I put together an API for any new apps to gain access to the main app cache. There was also the required functionality to reproduce in that the query window needs to go away when the main application is closed. I wanted to make sure this always happened. Otherwise the users might get suspicious if an orphan window stuck around when the main app went away. In addition, the new stand alone app needed the main app to work.

Therefore I implemented a two phased approach to ensuring orphan children did not stick around. Before the main application shuts down, it will send window messages to the child stand alone apps, telling them to exit as well. This seemed appropriate. However I also wanted to handle the special case where the main application aborts or is killed. In that scenario the main app does not get a change to inform the child apps to quit. Therefore I also implemented a polling functionality in the child apps. They ping the main app every 2 seconds via windows message calls. If they do not hear from the main app, they assume it has died and they end their processes.

By now I had figured that I had a solid design. The parent or child applications may abort due to exceptional circumstances. However there did not seem to be any way for there to be lingering orphan children applications sticking around. This is why I found it strange that a maintenance developer thought that a particular error encountered by the user was due to the fact that the main app had died causing problems for the stand alone app. While I agreed this might be possible, it was highly unlikely. I informed this maintenance developer that he had better go back to the chalk board and try to figure out what was really going on. Solid design is, well, solid.