3 ms·
Another pattern especially for ambiguous Boolean parameters I also find helpful is something like (in pseudo-ish code): enum SortDirection { FORWARD, REVERSE
by vore 6y ago
Another pattern especially for ambiguous Boolean parameters I also find helpful is something like (in pseudo-ish code):
enum SortDirection { FORWARD, REVERSE }
sort(direction : SortDirection = SortDirection.FORWARD) { ... }
['Ford', 'BMW', 'Volvo'].sort()
['Ford', 'BMW', 'Volvo'].sort(SortDirection.REVERSE)
- kllrnohj 6y agoYup, that's the API design tweak that QT recommends as well. But it's a lot more boilerplate, and that sort of boilerplate basically never happens for internal-only methods. Named parameters is basically the middle ground solution for the "quick" hacks that have a tendency to be rather permanent hacks.