Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public interface IFunctionality1
- {
- void DoStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases);
- }
- public interface IFunctionality2
- {
- void DoMoreStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases);
- }
- public class ActualFunctionality1 : IFunctionality1
- {
- public void DoStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases)
- {
- cases = MergeRelatedCases(cases);
- //code block for the first functionality should have been moved here
- }
- private IReadOnlyList<Case> MergeRelatedCases(IReadOnlyList casesToMerge)
- {
- //code to do the merging goes here
- }
- }
- public class ActualFunctionality2 : IFunctionality2
- {
- public void DoStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases)
- {
- //code block for the second functionality should have been moved here
- }
- }
- //common variables used accross all functionalities
- var functionality1 = ObjectFactory.GetInstance<IFunctionality1>();
- var functionality2 = ObjectFactory.GetInstance<IFunctionality2>();
- var persons = personsRepo.GetPersons(filterParameters);
- var cases = casesRepo.GetCases();
- //call the updated component for the first functionality here
- //now it does not change the shared variable anymore
- functionality1(persons, cases)
- //call the component for the second functionality here
- functionality2(persons, cases)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement