c#


Design pattern for similar processing steps, but with slight variations


What is a good design pattern to implement a feature, where processing of data is pretty similar, except for variations in may be few steps... I initially thought that Chain-Of-Responsibility may be suitable... but it doesn't feel like the right choice.. If I'd know the name of appropriate pattern, I'd search it on internet.. but I don't know what pattern to use here.. So please suggest one.
To be clear with an example -
Scenario 1
Step 1
Step 2
Step 3
Step 4
Scenario 2
Step 1
Step A
Step 3
Step 4
Would like to implement the feature in such a way that minimum code duplication is necessary.
I do realize that something will have to chain the necessary steps together at the start, like a factory, based on the scenario.
What you've described may be solved by pipelining, where a set of steps are linked together to pass data through a "pipeline". There are different means of accomplishing this in different languages, but here is an example with data flow pipelining in .NET (C#): http://msdn.microsoft.com/en-us/library/ff963548.aspx and an alternative in Java using Apache Commons: http://commons.apache.org/sandbox/commons-pipeline/pipeline_basics.html
From your example it seems to me that Template pattern would be more appropriate when sequence/steps are always the same but one or more steps has different implementations.
In case number of steps variate much more, for example completely different step order, sometimes just few steps sometimes some steps are skipped than Strategy pattern would be better solution.
However if you need to apply different rules after another (like graphics filters) on a object than pipeline would be more appropriate. As soon as one "filter" finishes you give the object to the next one in the pipeline

Related Links

Combo box autocomplete blanks when down key pressed C# windows
XNA 4.0.4 use Z-buffer in rendertarget
IP/name resolve conflict
Sort a List based on a Pre-Sorted List
Constructing an enum instance [duplicate]
Cant access C# static class
MVC 5 not validating StringLength attribute properly
How do I bind an ObservableCollection to an AvalonDock DocumentPaneGroup?
Get concrete property that implements type
ASP.NET website and ms excel integration
Call a C# .net .dll script using PHP
Invalid PDF digital signature in WinRT app
Coordinate API OAuth2 authentication with refresh token
SELECT ##IDENTITY in Access always returning 0
C# Wpf Visual Studio Meaninglessly Insists My Class Does Not Exist In Namespace
Change the default TaskFactory?

Categories

HOME
logging
repository
ckan
gsm
azure-eventhub
liquibase
ebay-api
spss
where
query-string
terminal
powerquery
flowtype
scapy
obd-ii
ios-universal-links
minimax
mongoimport
ldap-query
ng2-charts
hdf5
luis
loader
spring-webflow
minimagick
multipart
mattermost
fastboot
ckeditor4.x
units-of-measurement
opencsv
storefront
node-soap
openvms
webmock
android-databinding
word-wrap
ssdp
socketcluster
php-mongodb
result
activeandroid
appcmd
extjs3
perldoc
ajv
jtextarea
cardview
jspx
require-handlebars
geokit
hfp
nimbus
boost-bind
archiva
window.location
pebble-js
bbedit
music-player
wordpress-plugin
android-contentresolver
magnet-uri
javapackager
roslyn-code-analysis
eaaccessory
android-networking
targetprocess
stderr
google-experiments
applinks
alpha-beta-pruning
fxmlloader
windows-search
visual-c#-express-2010
atg-dynamo
android-relativelayout
webshim
ardor3d
mencoder
extensibility
wpd
pudb
feincms
gssapi
esi
webpage-screenshot
waveout
dancer
nsscrollview
clgeocoder
jqtransform
javah
hp-trim
mdd
dojox.gfx
bootstrap-protocol
cstring
stackless

Resources

Encrypt Message



code
soft
python
ios
c
html
jquery
cloud
mobile