Click here to Skip to main content
15,890,579 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: What the Message for Update UI on DialogBase App? Pin
Moak29-Aug-09 0:09
Moak29-Aug-09 0:09 
QuestionIOCP memory question Pin
lcx31563382028-Aug-09 19:09
lcx31563382028-Aug-09 19:09 
AnswerRe: IOCP memory question Pin
Richard MacCutchan30-Aug-09 6:58
mveRichard MacCutchan30-Aug-09 6:58 
QuestionRe: IOCP memory question Pin
lcx31563382031-Aug-09 2:11
lcx31563382031-Aug-09 2:11 
AnswerRe: IOCP memory question Pin
Richard MacCutchan31-Aug-09 4:08
mveRichard MacCutchan31-Aug-09 4:08 
QuestionMake ActiveX have it's own thread Pin
manchukuo28-Aug-09 17:41
manchukuo28-Aug-09 17:41 
AnswerRe: Make ActiveX have it's own thread Pin
«_Superman_»30-Aug-09 21:24
professional«_Superman_»30-Aug-09 21:24 
Questionc++ Factory pattern for large number of different classes. (answered) Pin
Maximilien28-Aug-09 10:09
Maximilien28-Aug-09 10:09 
(don't know if this should be in the design forum, anyway, I'm coding in C++)

I have a factory that will eventually create many, many different objects.

usually, I have something like (pseudo-c++-ish):

#include "type1Class.h"
#include "type2Class.h"
#include "type3Class.h"
#include "type4Class.h"

// typeXClass derive from BaseClass.
static BaseClass* MyClass::Builder(ObjectType type)
{
  switch (type)
  {
    case type1: return new Type1Class;
    case type2: return new Type2Class;
    case type3: return new Type3Class;
    case type4: return new Type4Class;
    //...
  }
}


Now, for a small number of classes this is manageable; but for a large number of classes it creates a large number
of includes and a huge switch.

Is there another pattern or methodology to clean that potential mess ?

I known I can put all typeXClass.h includes in a separate include file and have that one included; that will reduce the number of lines; any other tips hints ?

Thanks.

--------- edit------
Thanks to Stuart and Cédric; I will have a look at their solution first thing after coffee next monday!

This signature was proudly tested on animals.

AnswerRe: c++ Factory pattern for large number of different classes. Pin
Garth J Lancaster28-Aug-09 14:26
professionalGarth J Lancaster28-Aug-09 14:26 
AnswerRe: c++ Factory pattern for large number of different classes. Pin
Stuart Dootson28-Aug-09 14:27
professionalStuart Dootson28-Aug-09 14:27 
GeneralRe: c++ Factory pattern for large number of different classes. Pin
Maximilien29-Aug-09 3:10
Maximilien29-Aug-09 3:10 
AnswerRe: c++ Factory pattern for large number of different classes. Pin
Cedric Moonen28-Aug-09 21:44
Cedric Moonen28-Aug-09 21:44 
AnswerRe: c++ Factory pattern for large number of different classes. (answered) Pin
Iain Clarke, Warrior Programmer29-Aug-09 5:42
Iain Clarke, Warrior Programmer29-Aug-09 5:42 
Question2 questions of rich edit Pin
includeh1028-Aug-09 10:03
includeh1028-Aug-09 10:03 
AnswerRe: 2 questions of rich edit Pin
Code-o-mat29-Aug-09 1:41
Code-o-mat29-Aug-09 1:41 
QuestionC/C++ code of Vernam Cipher Algorithm Pin
Munna Bhagat28-Aug-09 6:44
Munna Bhagat28-Aug-09 6:44 
AnswerRe: C/C++ code of Vernam Cipher Algorithm Pin
CPallini28-Aug-09 7:02
mveCPallini28-Aug-09 7:02 
QuestionRe: C/C++ code of Vernam Cipher Algorithm Pin
Maximilien28-Aug-09 7:45
Maximilien28-Aug-09 7:45 
AnswerRe: C/C++ code of Vernam Cipher Algorithm Pin
Michael Schubert29-Aug-09 0:28
Michael Schubert29-Aug-09 0:28 
QuestionC/C++ code of Vernam Cipher Algorithm Pin
Munna Bhagat28-Aug-09 6:41
Munna Bhagat28-Aug-09 6:41 
QuestionC/C++ code of Vernam Cipher Algorithm Pin
Munna Bhagat28-Aug-09 6:41
Munna Bhagat28-Aug-09 6:41 
QuestionAnti virus live update corrupting file mapped shared memory Pin
avijaya28-Aug-09 4:59
avijaya28-Aug-09 4:59 
QuestionRe: Anti virus live update corrupting file mapped shared memory Pin
Randor 28-Aug-09 6:09
professional Randor 28-Aug-09 6:09 
AnswerRe: Anti virus live update corrupting file mapped shared memory Pin
avijaya28-Aug-09 6:15
avijaya28-Aug-09 6:15 
QuestionAfxDumpStack Pin
Krishnakumartg28-Aug-09 3:35
Krishnakumartg28-Aug-09 3:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.