Last active
June 8, 2016 13:27
-
-
Save Kritner/8e734313797f83cb7cdec19a6402d5b9 to your computer and use it in GitHub Desktop.
Is this the mediator pattern?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public interface IGetData | |
{ | |
IEnumerable<MyData> Execute(); | |
} | |
public interface IProcessData | |
{ | |
IEnumerable<MyProcessedData> Execute(IEnumerable<MyData> data); | |
} | |
public interface IWriteData | |
{ | |
void Execute(IEnumerable<MyProcessedData> data); | |
} | |
// can this class be considered a mediator? I'm always unsure what to call these types of classes | |
public class DataProcessor | |
{ | |
private readonly IGetData _iGetData; | |
private readonly IProcessData _iProcessData; | |
private readonly IWriteData _iWriteData; | |
public DataProcessor(IGetData iGetData, IProcessData iProcessData, IWriteData iWriteData) | |
{ | |
_iGetData = iGetData; | |
_iProcessData = iProcessData; | |
_iWriteData = iWriteData; | |
} | |
public void Execute() | |
{ | |
var rawData = _iGetData.Execute(); | |
var processedData = _iProcessData.Execute(rawData); | |
_iWriteData.Execute(processedData); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment