You are not logged in. Your edit will be placed in a queue until it is peer reviewed.
We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.
- 3It is a little difficult to imagine that simply moving code to other objects reduces the number of code paths that need testing. It might become easier to see what tests need to be written, but an if-elseif-else is still 3 paths, no matter which class the logic belongs to.Greg Burghardt– Greg Burghardt2021-11-18 23:32:37 +00:00Commented Nov 18, 2021 at 23:32
- I agree with Greg here, and that is the reason that I ask this question. Refactoring only splits one function into many, but the total number of codepaths is still the same if you actually refactor properly and don't end up changing the algorithm.Magnus– Magnus2021-11-19 00:53:55 +00:00Commented Nov 19, 2021 at 0:53
- 1@FilipMilovanović: refactoring doesn't mean you completely rewrite the internals. It could simply mean you split the code into multiple functions - essentially giving a name to a group of statements without actually changing the number of code paths.Greg Burghardt– Greg Burghardt2021-11-19 12:22:36 +00:00Commented Nov 19, 2021 at 12:22
- 2@GregBurghardt: Let's say I flip a coin, roll a die, and pick one letter, all in one go. That's 2×6×26=312 possible outcomes. But if I have a separate coin flipper, that has 2 possible outcomes. A dice roller has 6 outcomes. A letter picker has 26 outcomes. So you now only write 2 coin picking tests, 6 dice rolling tests, and 26 letter picking tests, for a total of 34 tests. That's an almost 90% reduction in how many outcomes you need to test.Flater– Flater2021-11-21 09:54:01 +00:00Commented Nov 21, 2021 at 9:54
- 1@Caleth: And the need for 100% coverage of the state space dissolves due to rigorous unit testing of individual components; a handful of integration tests can confirm the integration of the components. If you demand 100% coverage, sure, then you have to cover 100%. But then you inherently choose to work hard, not smart; rendering the basis of the question moot.Flater– Flater2021-11-22 12:50:58 +00:00Commented Nov 22, 2021 at 12:50
| Show 3 more comments
How to Edit
- Correct minor typos or mistakes
- Clarify meaning without changing it
- Add related resources or links
- Always respect the author’s intent
- Don’t use edits to reply to the author
How to Format
- create code fences with backticks ` or tildes ~ ```
like so
``` - add language identifier to highlight code ```python
def function(foo):
print(foo)
``` - put returns between paragraphs
- for linebreak add 2 spaces at end
- _italic_ or **bold**
- indent code by 4 spaces
- backtick escapes
`like _so_` - quote by placing > at start of line
- to make links (use https whenever possible) <https://example.com>[example](https://example.com)<a href="https://example.com">example</a>
How to Tag
A tag is a keyword or label that categorizes your question with other, similar questions. Choose one or more (up to 5) tags that will help answerers to find and interpret your question.
- complete the sentence: my question is about...
- use tags that describe things or concepts that are essential, not incidental to your question
- favor using existing popular tags
- read the descriptions that appear below the tag
If your question is primarily about a topic for which you can't find a tag:
- combine multiple words into single-words with hyphens (e.g. design-patterns), up to a maximum of 35 characters
- creating new tags is a privilege; if you can't yet create a tag you need, then post this question without it, then ask the community to create it for you