On Tue, 21 Oct 2003 02:39:30 +0200 (Romance Daylight Time) Vadim Zeitlin <[EMAIL PROTECTED]> wrote: > RW> and develope my new dialog, or is there some standard for reusability?
> If you can't use the existing dialog, extract the part of it which you can > use in a base class and derive the existing class and your new dialog from > it. It may be a bit more work now than cut-and-pasting but it's a huge > saving globally. after spending some time with the code, and playing with an alternative or two, i'm leaning towards using things like the Factory pattern to extract and fold together various bits of replicated code. does anyone have any strong thoughts about this approach, positive or negative? the gist of it is that much of the replicated code in the various folder dialogs doesn't really need to be in the classes in question; it refers primarily to wxWindows GUI stuff and not to the encapsulating class, which makes it ideal for refactoring using a Factory pattern. the idea is to create a class like "wxGUIObjectFactory" with methods for creating buttons, panes, etc. this snippet of code: wxButton *btnAdd = new wxButton(this, Button_Add, _("&Add...")); c = new wxLayoutConstraints; c->width.Absolute(wBtn); c->height.Absolute(hBtn); c->right.SameAs(btnEdit, wxRight); c->bottom.Above(btnCopy, -LAYOUT_Y_MARGIN); btnAdd->SetConstraints(c); becomes: wxbutton *btnAdd = factory.nextButton( box, wxAbove, wxRight, btnCopy, btnEdit, Button_Add, _("&Add...")); or something very much like that. with a series of small, carefully chosen refactorings like this, i can probably fold up nearly all the replicated code without messing with the class structure, and then be in a good position to create another FolderDialog w/o duplicating anything. richard -- Richard Welty [EMAIL PROTECTED] Averill Park Networking 518-573-7592 Java, PHP, PostgreSQL, Unix, Linux, IP Network Engineering, Security ------------------------------------------------------- This SF.net email is sponsored by OSDN developer relations Here's your chance to show off your extensive product knowledge We want to know what you know. Tell us and you have a chance to win $100 http://www.zoomerang.com/survey.zgi?HRPT1X3RYQNC5V4MLNSV3E54 _______________________________________________ Mahogany-Developers mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/mahogany-developers