News for hackers. Stuff that matters.
Re:Good Software Development Habits by arccy on Sunday November 17, 2024 @02:26PM (#42166363)
+1, have 2 implementations that each have an independent branch point? if you combine them you have a function with 2 bool parameters, and 4 possible states to test, 2 of which you might never need
Re:Good Software Development Habits by hinkley on Sunday November 17, 2024 @04:32PM (#42167501)
It’s difficult to convince people that once you consider the testing pyramid, it’s not just 2 + 2 + 2 < 2 x 2 x 2 but also 2 + 2 < 2 x 2
Re:Good Software Development Habits by silvestrov on Sunday November 17, 2024 @05:39PM (#42168010)
"The greatest shortcoming of the human race is our inability to understand the exponential function”.

https://en.wikipedia.org/wiki/Albert_Allen_Bartlett

Re:Good Software Development Habits by Aeolun on Sunday November 17, 2024 @07:10PM (#42168511)
There’s ways to write this that still keep the entrypoint to a single function. Having different function names as your parameters doesn’t make them any less so.
Re:Good Software Development Habits by cma on Monday November 18, 2024 @02:50AM (#42170578)
A very common one is two booleans with one combination of them being an invalid state (e.g. never are both bools true in a valid state but all can be false or a mixture). Use an enum instead that represents only the three valid cases.
Re:Good Software Development Habits by somethingsome on Tuesday November 19, 2024 @03:25PM (#42187714)
Combinatorial explosion of states is a nightmare, IME it means that the abstraction behind is not the right one.

You really don't want to have a function that branches a lot inside. It's very difficult to test.

When you think of adding a flag, run in your head 2^n, this will give you the least number of tests needed. Do you really want to write all of them?