Skip to main content
4 events
when toggle format what by license comment
Oct 1, 2019 at 12:05 comment added Kilian Foth Either have C be (vacuously) IDisposable anyway, or introduce your own finalize() method into A with a no-op default implementation.
Oct 1, 2019 at 12:03 comment added kondziu Maybe more concrete example: Let's say we have parent A class. B and C classes inherits from A. Additionally B implements IDisposable. C doesn't implement IDisposable because it doesn't anything to clean-up. List<A> contains some B and C. I want to dispose all B instances to not make memory leaks. I don't want to force to implement IDisposable on all A children when not every child have some resources to clean-up.
Oct 1, 2019 at 11:46 comment added Doc Brown I am pretty sure if this is a good solution depends heavily of what A, B, processA and processB represent, how often they are supposed to be changed, how the whole class hierarchy looks like. It also depends on the context of where the process() method will be called, and if we are writing a throw-away program or a reusable library, and a dozen other things. I don't like this kind of contrived examples where anyone can pick the interpretation he/she likes best.
Oct 1, 2019 at 11:37 history answered Kilian Foth CC BY-SA 4.0