while designing my api, i am thinking about how i would like to model the following behavior.
option 1 seems more logical, but with that comes enforcing invariants such as checking if the spreadsheet actually belongs to the workbook.
option 2 seems strange a spreadsheet knows how to remove himself, but in fact the spreadsheet has a reference to its parent workbook and can delegate the call directly to him.
or is this really not a valid case since the workbook would need to validate it spreadsheet no matter what?? thoughts?
Workbook wb = new Workbook("Finances");
Spreadsheet ss = wb.CreateSpreadsheet("Bob's");
// option 1:
wb.RemoveSheet(ss);
// option 2:
ss.RemoveFromWorkbook();
Thank You everyone
I would use wb.Sheets.Remove(ss). This allows separation of responsibilities as the Sheets object is a collection of Spreadsheets. This also allows the concept later on that a sheet might be in multiple workbooks.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With