c# - What pattern to use to be more flexible? -


i building interface read, validate, convert , store data. in way 2 systems can cummunicate each other.

i have created generic flow works fine , extensible:

  • iprocessor< p, s> -> proces() : void

  • iprovider -> getitems() : ienumerable< string>

  • ivalidator -> validate(string) : void

  • iparser< p > -> parse(string) : p

  • imapper< p, s> -> map(p) : s

  • istorage< s> -> save(s)

  • new processor(iprovider, ivalidator, iparser< p>, imapper< p, s>, istorage< s>)

the problem there business rule states p must mapped s1 or s2 depending on value. how alter structure, more flexible?

add interface:

  • ibusinessrule<p, s> -> maptos1(p) : bool

initialize mapper it:

  • new mapper(ibusinessrule<p, s>)

p.s. mean s1 : s , s2 : s.


Comments

Popular posts from this blog

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -

YouTubePlayerFragment cannot be cast to android.support.v4.app.Fragment -