C++ Logo


Advanced search

Subject: Re: [std-proposals] Friend namespace
From: Ville Voutilainen (ville.voutilainen_at_[hidden])
Date: 2020-12-06 08:59:20

On Sun, 6 Dec 2020 at 16:31, Arthur O'Dwyer via Std-Proposals
<std-proposals_at_[hidden]> wrote:
> On Sun, Dec 6, 2020 at 4:24 AM Peter C++ via Std-Proposals <std-proposals_at_[hidden]> wrote:
>> To start with, you should not test private stuff. It is private, so it might change. Binding tests to the private parts makes them harder to change, because of the tests, that should make software easier to refactor and change.
> I agree with Peter here.
> "Refactoring for testability" is definitely a thing. This generally involves at least two parts, and maybe more:
> (1) Make sure all your dependencies are injected
> (2) Make sure all your functionality is exposed

1) sometimes you do want to test your implementation details, i.e...
your.. ..implementation, *gasp*
2) the cost of recfactoring-for-testability may overshadow its benefits
3) so when facing that situation, punch the conditional friend
peephole open and use it in your tests
4) treat all the advice in this thread, including this one,
judiciously, and make engineering decisions
that suit your problem domain, instead of following dogma
5) profit!

STD-PROPOSALS list run by std-proposals-owner@lists.isocpp.org

Standard Proposals Archives on Google Groups