[Interest] deprecating class methods gracefully

René J.V. Bertin rjvbertin at gmail.com
Sun Nov 6 18:33:41 CET 2016


Hi,

This isn't essentially a Qt-specific question, but one about a situation I hope Qt may have found an elegant solution for.

Say I have a class (B) that at first I thought would need a (static) method with a mode argument with a default setting. That method is declared inline but that shouldn't make a difference, I think. It also overrides a method from the parent class (A), which is more relevant.
Over time I've come to realise that the mode argument is moot for this particular method, because there is no justified use case for the non-default mode.

I could simply remove the method in question so that code builds to use the now no longer overridden parent method. However, this class is provided by a low-level library that's used by lots of code, and I'd prefer not to oblige all that code to be rebuilt immediately.

So what I'm looking for is a way to provide the function so that runtime dependencies of existing binaries continue to be satisfied, but in such a way that newly built code no longer references it.

Sadly this class was never designed for this, so there's no private implementation hidden behind a d-pointer which would make this a trivial problem.

Any suggestions how to tackle this problem? My current solution suppresses the class B definition in the headerfile when it's being included in the class A implementation file, and puts a transitional implementation of class B containing only the deprecated method in that implementation file. That seems to work, but feels like a hack ...

Thanks,
René



More information about the Interest mailing list