Re: abstract factory -- a doubt ?



vivekaseeja@xxxxxxxxx wrote:


Phlip wrote:
Duplication. Without the factory, then there are lots of 'new' statements
scattered around, and sometimes there are more 'if' statements that
detect a type code. The factory converts type codes to real types, in one
place, and this lets client code use the types without so many 'if'
statements.

okay , makes sense. could you elaborate a bit more as to what "converts
type codes to real types" mean (maybe with an example) ?

All programs have boundaries, where raw data comes in, and they are turned
into internal types with virtual methods. So consider the data 'A', 'B',
and 'C'. This is odious:

if (TypeCode == 'B')
doBthings(TypeCode);

This is clean:

Type.doThings();

Also , somehow
it seems like that the complexity is transffered ( though now invisible
to the client ) ?

The client, in my example, no longer sees the 'B'. I turned a visible 'if'
statement into the invisible thing that selects with virtual version of
doThings() to call.

--
Phlip
http://www.greencheese.us/ZeekLand <-- NOT a blog!!!
.



Relevant Pages

  • Re: abstract factory -- a doubt ?
    ... The factory converts type codes to real types, in one place, ... and this lets client code use the types without so many 'if' statements. ...
    (comp.object)
  • Re: abstract factory -- a doubt ?
    ... The factory converts type codes to real types, in one place, ... and this lets client code use the types without so many 'if' statements. ...
    (comp.object)