Tag Info

Hot answers tagged

15

Just take a number in the range [minVal, maxVal-1] and add 1 if it is greater or equal to lastNum int ChooseNewNumber(lastNum){ minVal = 0; maxVal = N; if(minVal > lastNum || lastNum > maxVal){ //if lastNum is outside range then just take full range return RandomIntWithinInclusiveRange(minVal, maxVal); } random = ...


6

Just choose between 1 and N and return 0 if the value is lastNum. int ChooseNewNumber(lastNum){ random = RandomIntWithinInclusiveRange(1, N); if (random == lastNum) { return 0; } return random; } Or the shorter version, if you prefer: int ChooseNewNumber(lastNum){ random = RandomIntWithinInclusiveRange(1, N); return ...


5

Have you considered the possibility of doing a "skunk works" level add-on? Whenever I've found the kind of push-back you're describing I consider how much effort it would take to get fully off the ground and how much it would take to get it "pseudo" working. If you believe in the product, and you believe in the need to upgrade this product, then it might ...


2

I'll attempt if not answer your question, at least give some hints. As a side note, I've contributed to refactoring of several medium-sized projects (although not as big as yours), especially the ones which had data access directly mixed with business code, so the answer is partially based on my personal experience. Identify the problem The first thing I ...


1

My opinion is that you should do nothing, meaning you should not add any new tests. I stress that this is an opinion, and it actually depends on the way you perceive the expectations from the object. Do you think the user of the class would like to supply a strategy for tax calculation? If he doesn't care, then the tests should reflect that, and the ...


1

Contrary to the other answers, it is important to note that some ways of testing can become fragile when the system under test (SUT) is refactored, if the test is whitebox. If I'm using a mocking framework that verifies the order of the methods called on the mocks (when the order is irrelevant because the calls are side-effect free); then if my code is ...



Only top voted, non community-wiki answers of a minimum length are eligible