PDA

View Full Version : Program design best practices



poporacer
9th November 2010, 20:08
I am writing a program that has a stacked widget and some of the pages are used for database entry/correction other pages are used for reporting/printing. There are methods for populating the lineedits, comboboxes, entering new data, etc. Several of the pages have methods that are almost identical. I wanted to know what the best or appropriate methods would be. From what I can tell my options would be:

1. Have all the methods for populating/verifying and manipulation all in the class for the widget that contains the stacked widget.
2. Create a class (with a header and cpp file) for each page of the stacked widgets and call each method as needed.

What would be the best method? Or is there a better way?

Zlatomir
9th November 2010, 20:17
I would go with number two, since it's more modular, and it would be easier to implement/test each module separately and later add new modules if necessary.

If you go with your first design remember that in C++ you have templates which can be used to write generic functions (so that you don't repeat the same code again and again)