The structure of my application is layered. The GUI is handled by Controllers, the Controllers each have a Service (which is responsible for business logic). For context, when a button is pressed, there is a method in the Controller that calls the respective method from the Service, in addition to other GUI-related stuff.
My question is, if I need to have the methods "Create copy of excel and open it" and "Only create copy of excel" in Service, how can I minimize the redundancy of the 2 methods?
Also, if I choose to write these 2 methods separately in Service, in the Controller there will also need to exist 2 methods with similar names to those in Service, each of them containing a single line of code that calls the respective method from Service. How can I write this code as clean as possible?
Create two methods:
CreateCopyOfExcel(/*...*/)
OpenExcel(/*...*/)
If you want to create a copy of Excel and open it, call both in sequence:
CreateCopyOfExcel(/*...*/);
OpenExcel(/*...*/);
If you you only want to create the copy, call only that method:
CreateCopyOfExcel(/*...*/);