3 ms·
Interesting. I usually default to writing functions over classes for the simple reason that it makes testing much simpler as you just need to test inputs versu
by mrep 6y ago
Interesting. I usually default to writing functions over classes for the simple reason that it makes testing much simpler as you just need to test inputs versus outputs to a function.
With classes, you sometimes have to manage and test the state of it. For a database example of something I had to design a while back, it required me to manage 4 different state transitions each one depending on the state of the previous one. Thus, I ended up with this long test case running through each transition which was not ideal. Granted, I could have split the state transitions into multiple tests by setting up the internal state manually in for each test/transition, but I prefer not to fiddle with internal state in tests.