Re: abstract factory -- a doubt ?
- From: Phlip <phlip2005@xxxxxxxxx>
- Date: Tue, 25 Apr 2006 17:12:20 GMT
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!!!
.
- References:
- abstract factory -- a doubt ?
- From: viveklinux
- Re: abstract factory -- a doubt ?
- From: Phlip
- Re: abstract factory -- a doubt ?
- From: vivekaseeja
- abstract factory -- a doubt ?
- Prev by Date: Re: abstract factory -- a doubt ?
- Next by Date: Re: Question on LSP
- Previous by thread: Re: abstract factory -- a doubt ?
- Next by thread: Re: abstract factory -- a doubt ?
- Index(es):
Relevant Pages
|