Testing and testability in KDE PIM

Daniel Vrátil dvratil at kde.org
Thu Nov 1 12:10:39 GMT 2018


On Wednesday, 31 October 2018 14:32:46 CET Denis Kurz wrote:
> Am Mittwoch, 31. Oktober 2018, 14:07:39 CET schrieb Denis Kurz:
> > How are chances to land mere refactoring changes, like [...]
> 
> I forgot to mention a kind of refactoring that I have a particular interest
> in: How about refactorings that improve readability or maintainability or
> testability, but, in theory, have a negative impact on performance, even if
> no benchmark has ever shown that the code in question is critical for
> overall performance?
> 
> Refactorings that could fit that description: making a method virtual
> although production doesn't require it to be virtual (special case: extract
> an interface to be able to mock or stub a class), or replacing conditions,
> or switch statements, with polymorphism.
> 
> The answer is quite clear if a patch doesn't deliver, so assume that the
> patch really does improve read/maintain/test-ability.

This depends a lot on a wider context: if you make virtual a method which gets 
called in a tight loop, I won't be happy. If you do it in a method that gets 
called once per each SQL query executed then I don't really mind.

That said I've recently grew quite fond of CRTP [0] instead of using virtual 
methods in internal code where the implementation itself doesn't require the 
method to be virtual, and passing lambda functions as callbacks to customize 
behavior, which IMO helps greatly with separation of concerns (but one has to 
be careful not to overdo it, otherwise you end up with a lambda hell).

These things need to be judged and considered on case-by-case basis, I would 
say that common sense and gut feeling are the best guides here. Or just asking 
someone else for second opinion when unsure :-)


Dan

[0] https://www.fluentcpp.com/2017/05/12/curiously-recurring-template-pattern/



-- 
Daniel Vrátil
www.dvratil.cz | dvratil at kde.org
IRC: dvratil on Freenode (#kde, #kontact, #akonadi, #fedora-kde)

GPG Key: 0x4D69557AECB13683
Fingerprint: 0ABD FA55 A4E6 BEA9 9A83 EA97 4D69 557A ECB1 3683
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-pim/attachments/20181101/ac50e129/attachment.sig>


More information about the kde-pim mailing list