I remember discussing this pattern with you back in 2018 after a team member put try...catch clauses in nearly all methods 😂. Keep up the good work Patrick 👌😁
Nice explanation! I have one question, if I use DI to get the instance of service, and all these three services implement the same interface, how to resolve them then? thanks!
William, you can use DI to get the initial instances, but if you need to get instances dynamically, that could be difficult to achieve. Overall, I think the best way would be to use a Factory.
Don't you break the open close principal with the second example? Would it be better to made this size check in the implementation of Resize class, before return the SaveFile?
These tips on design patterns are lit, mr. Pat!
Thank you so much!
I remember discussing this pattern with you back in 2018 after a team member put try...catch clauses in nearly all methods 😂. Keep up the good work Patrick 👌😁
I remember... 🙂
Won’t the SaveFileAsync original method be called twice when the size is over a megabyte this way?
Nice explanation! I have one question, if I use DI to get the instance of service, and all these three services implement the same interface, how to resolve them then? thanks!
William, you can use DI to get the initial instances, but if you need to get instances dynamically, that could be difficult to achieve. Overall, I think the best way would be to use a Factory.
@@TechWithPat Thanks for your reply!
Don't you break the open close principal with the second example? Would it be better to made this size check in the implementation of Resize class, before return the SaveFile?
That's a valid option, I hesitated to include this check in the Resize class.