c# - Is this strategy pattern? -
a little background:
in system developing, there various types of csv files read , saved contents in different database tables. since changing behavior based on inputs, studies decorator, , strategy patterns , came following solution system.
first created following interfaces.
icdrmapperreads each line given csv file , maps object after running validations/modifications (if any). there many concrete implementations each cdr type.icdrreadertakes input csv file , reads each line , pass mapper. each reader implementation decorated mef metadataicdrenginecan locate correct 1 on fly. interface has many implementations each cdr type.icdrengineimplementation uses mef metadata locate matchingicdrreaderimplementation. has 1 implementation.
then, have created abstractcdrreader , abstractcdrmapper , used decorator pattern delegate specific implementations different concrete classes.
abstractcdrreader selects correct icdrmapper implementation based on mef metadata engine does.
following generated class diagram.

so questions are,
is strategy pattern or different one?
is there way improve design next time need read whole new different csv file, can implementation quickly?
you've described architecture of part of system. uses few design patterns:
- abstract factory (icdrengine process of creation concrete implementations of icdrreader, icdrmapper),
 - 2 implementations of strategy patern (icdrreader, icdrmapper hierarchies),
 - you mentioned decorator (though don't see class diagram - either incomplete or misunderstood called decorator).
 - the relation between mapper , reader hierarchies represents bridge pattern if i'm not mistaken.
 
as me architecture looks , flexible. i'm not sure expect improve easier adding ability read new csv format - need add new implementation of icdrreader, don't you? easy enough point of view , nothing should improved particular 'problem'.
Comments
Post a Comment