Advertisement
Guest User

Untitled

a guest
Oct 20th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. public interface IFunctionality1
  2. {
  3. void DoStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases);
  4. }
  5.  
  6. public interface IFunctionality2
  7. {
  8. void DoMoreStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases);
  9. }
  10.  
  11. public class ActualFunctionality1 : IFunctionality1
  12. {
  13. public void DoStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases)
  14. {
  15. cases = MergeRelatedCases(cases);
  16.  
  17. //code block for the first functionality should have been moved here
  18. }
  19.  
  20. private IReadOnlyList<Case> MergeRelatedCases(IReadOnlyList casesToMerge)
  21. {
  22. //code to do the merging goes here
  23. }
  24. }
  25.  
  26. public class ActualFunctionality2 : IFunctionality2
  27. {
  28. public void DoStuff(IReadOnlyList<Person> persons, IReadOnlyList<Case> cases)
  29. {
  30. //code block for the second functionality should have been moved here
  31. }
  32. }
  33.  
  34. //common variables used accross all functionalities
  35. var functionality1 = ObjectFactory.GetInstance<IFunctionality1>();
  36. var functionality2 = ObjectFactory.GetInstance<IFunctionality2>();
  37.  
  38. var persons = personsRepo.GetPersons(filterParameters);
  39. var cases = casesRepo.GetCases();
  40.  
  41.  
  42. //call the updated component for the first functionality here
  43. //now it does not change the shared variable anymore
  44. functionality1(persons, cases)
  45.  
  46. //call the component for the second functionality here
  47. functionality2(persons, cases)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement