Sybase, Inc. Navigational Bar

Powersoft Tools

Tip #9 - Reduce Your Compile Times - Drastically!

Power++ project with 3 targetsThe Patient: In this sample project, all three forms will be using WTransaction and WQuery objects. This is a simple Master/Detail project. In the Master form, a person is selected and then the user will click on either Address or Family and Create the appropriate form. A parameter is passed from the Master to the Detail so that the query done will return only the details of the selected person.

Now consider how all these Power++ forms are represented. Each form exists in the target directory as a WXF file. When it comes time to compile, for any WXF file that needs to be built, Power++ will generate a CPP and an HPP file in the Release subdirectory. Power++ uses timestamps to determine if a form needs to be rebuilt.

Back to the original project, since Master form is passing information to the other forms, it will need to include the other forms' HPP files. The #include would normally be in the Master's HPP file. Also, the Detail forms may (or may not) need to pass information back to the Master form.

What if the Detail forms do need to pass information back to the Master form? This would mean that the Detail forms would have to include the HPP of the Master form. [this problem is discussed in Week2 - see week2 point 3 for further information]

Header file inclusion diagramThis usually would be accomplished by each Detail class using a forward declarator of itself in the Detail's HPP and then it includes the Master's HPP afterwards. So the inclusion of header files might be represented by the diagram at left. The Master.hpp includes the headers of all other forms, and they in turn include the Master.hpp (notice that they include Master.hpp from the CPP section of the WXF file - not necessary but very useful for this example).


The Symptom: Whenever any change is made to Detail_Family.WXF, Power++ recompiles all files. In fact, whenever any change is made to any form, Power++ is forced to recompile all forms (in this particular case). Now consider that your project has 20+ forms! Power++ may be fast, but even that would be time-consuming if, for instance, I wanted to make a pushbutton on FormX to have the 'Default' property to be true. I then try to recompile and I now have 20 files to recompile and link.


The Diagnosis: A change is made to Detail_Family.WXF so Power++ must regenerate both the HPP and the CPP files. Since Master.WXF has an #include "Detail_Family.hpp" and it has changed, then Master.cpp must be recompiled (note here that Master.WXF does not regenerate its own CPP and HPP files - it just recompiles them). Likewise, since Detail_Address includes Master.hpp and it in turn includes Detail_Family.hpp, then Detail_Address must also be recompiled. This is the root of the problem. Similar problems can result when using FDX or any bi-directional form communication.


The Prognosis: This can be solved by moving the includes that Master.WXF has to the CPP section. Master.hpp will now need forward declarators of all Classes that it uses in it header files. Here is the change that would be made to the Master.WXF:

Forward Declarations of Classes DiagramNow, when you change Detail_Family.WXF, it regenerates the CPP and HPP files. The Master.WXF will still have to be recompiled, but since Master.WXF did not regenerate its own files and because Master.hpp does not include Detail_Family.hpp, then no other files must be recompiled. Maybe in this small project it won't make much difference since it means that any change will result in two object file compiles instead of three, but when you consider an industrial strength application that has 20+ files, this would bring the number of compiles down from 20 to 2!

I worked on a project just like this recently. By changing the one WXF file that was doing the mastering, I reduced the compile time of a minor change to 20% of what they were.



Click here to see Tip#10

Return to Power++ Home Page.


to top of page

Copyright © 1999 Sybase, Inc. All Rights Reserved.
Privacy Policy
Legal