✅ How should I structure 'exit points' in my program?
Hey guys.
I'm working solo on a project that involves opening an Excel file, sorting through and transforming into a DataSet. I'm not very experienced and unfortunately am working on this completely solo. This will then be used to create invoices on an ERP; as such, it'll be imported as a .dll into that program.
I have a main class inherits from one of the ERPs native classes and it calls methods from another class I wrote myself. That second class has methods to open an Excel file, sort through it with some rules and transforming the results into a DataSet I'll then use to make the invoices. I've tried my best to write fallbacks in the code in case the file isn't present, user doesn't have permission to access it, etc.
Question 1: if something goes wrong in the secondary class (for example Excel file is already in use), how do I make it so the whole thing stops. Right now I'm just "return"ing back out of the secondary class to the main one, but that one then has nothing to stop it going forwards.
Question 2: I currently have all the secondary classes methods in its constructor meaning that I just have to instanciate it in the main class, and the whole Excel manipulation and DataSet creation happens at once. Would it be a better idea to make those methods public, remove from constructor and call them one by one on the main class?
Thank you kindly!!
I'm working solo on a project that involves opening an Excel file, sorting through and transforming into a DataSet. I'm not very experienced and unfortunately am working on this completely solo. This will then be used to create invoices on an ERP; as such, it'll be imported as a .dll into that program.
I have a main class inherits from one of the ERPs native classes and it calls methods from another class I wrote myself. That second class has methods to open an Excel file, sort through it with some rules and transforming the results into a DataSet I'll then use to make the invoices. I've tried my best to write fallbacks in the code in case the file isn't present, user doesn't have permission to access it, etc.
Question 1: if something goes wrong in the secondary class (for example Excel file is already in use), how do I make it so the whole thing stops. Right now I'm just "return"ing back out of the secondary class to the main one, but that one then has nothing to stop it going forwards.
Question 2: I currently have all the secondary classes methods in its constructor meaning that I just have to instanciate it in the main class, and the whole Excel manipulation and DataSet creation happens at once. Would it be a better idea to make those methods public, remove from constructor and call them one by one on the main class?
Thank you kindly!!