-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make TwoWire methods virtual #331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
This allows them to be overridden by downstream projects that need to subclass TwoWire
I still think this is a valuable change with basically no downsides - let me know if anyone has feedback, but I'd love to see this get merged! |
Are you sure about this?
In one of my libraries, adding a single virtual method in the entire library caused the flash memory consumption to go up by 50% (from ~1100 bytes to ~1600 bytes). This class already has virtual methods, so the difference won't be as drastic, but it might be worth double-checking. Anyway, this is just a drive-by comment, and I'm not an expert on the TwoWire library. But adding 1-2 virtual methods to class that already has a handful of other virtual methods wouldn't concern me too much. But adding ~20 virtual methods to a class seems like something to be more careful about, to avoid unintended side-effects. |
Valid points that I hadn't considered! My end goal is to make it possible for this software implementation of TwoWire to neatly subclass TwoWire and override the relevant methods. The specific use case I had could certainly have been accomplished through a narrower set of virtual methods, but since the class already has some virtual methods (in particular, |
Fair enough - I no longer even remember the details of what I wanted to accomplish with this subclassing, but if it matters to me in the future, I'll go with the approach from 396. |
This allows them to be overridden by downstream projects that need to subclass TwoWire
For an example of a project that currently subclasses TwoWire and would benefit from this functionality, see https://github.com/Testato/SoftwareWire