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.
Required fields*
- 1What I have experienced, though, is that my first design only worked for some simple cases and I later realized that I need a more general solution. Developing the more general solution required more tests while the original tests for the special cases won't work again. I found it acceptable to (temporarily) remove those tests while I develop the more general solution, adding them back once time is ready.5gon12eder– 5gon12eder2017-01-09 05:23:54 +00:00Commented Jan 9, 2017 at 5:23
- 3I'm not convinced refactoring is a way to generalize code (outside of the artificial "design patterns" space, of course) or escape local maxima. Refactoring tidies up code, but it won't help you discover a better solution.Andres F.– Andres F.2017-01-09 15:15:03 +00:00Commented Jan 9, 2017 at 15:15
- 2@Sklivvz Understood, but I don't think it works that way outside toy examples like the ones you posted. Also, it helped you that your function was named "double"; in a way you already knew the answer. TDD definitely helps when you more or less know the answer but want to write it "cleanly". It wouldn't help for discovering algorithms or writing really complex code. This is why Ron Jeffries failed to solve Sudoku this way; you cannot implement an algorithm you're unfamiliar with by TDD'ing it out of obscurity.Andres F.– Andres F.2017-01-09 19:59:08 +00:00Commented Jan 9, 2017 at 19:59
- 1@VaughnCato Ok, now I'm in the position of either trusting you or being skeptical (which would be rude, so let's not do that). Let's just say, in my experience, it doesn't work like you say. I've never seen a reasonably complex algorithm evolved out of TDD. Maybe my experience is too limited :)Andres F.– Andres F.2017-01-10 17:28:27 +00:00Commented Jan 10, 2017 at 17:28
- 2@Sklivvz "As long as you can write the appropriate tests" is precisely the point: it sounds like begging the question to me. What I'm saying is that you often cannot. Thinking about an algorithm or a solver is not made easier by writing tests first. You must look at the whole picture first. Trying scenarios is of course necessary, but note TDD is not about writing scenarios: TDD is about test driving the design! You cannot drive the design of a Sudoku solver (or a new solver for a different game) by writing tests first. As anecdotidal evidence (which isn't enough): Jeffries couldn't.Andres F.– Andres F.2017-01-10 18:52:15 +00:00Commented Jan 10, 2017 at 18:52
| Show 15 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