Skip to main content

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.

4
  • These are really good observations. I had thought of the inline-and-factoring out earlier, but as merge is surprisingly messy, edge-case-wise (as well as useful as a standalone) the idea of doing it as a separate function made more sense. However, the style of doing it inline in its basic form and then factoring it out at the blue-hat stage really seems to be right and very much what I was looking for. Commented Nov 9, 2016 at 19:58
  • @RayToal - I actually lean toward the approach of fully testing the merge operation before doing the sort (as well as separate testing of the partition operation). I think that the claimed benefits emergent design comes from slowly working toward a known goal. In the case of mergesort, I don't think the goal is sorting in general (because then you'll end up with bubble sort). You know the basic operations, so you work toward those operations; the sort is mostly an afterthought. Commented Nov 9, 2016 at 20:33
  • 1
    There's a forth option. Pass the merge function into mergesort and mock its behavior. Then go back and implement merge test first. Delegates are awesome™. Commented Nov 9, 2016 at 21:08
  • @RubberDuck Mocking a integral part of the core domain could lead to some troubles, more specifically when you run the program and the mocked and merge function differ in the least detail. An approach like that should be left for instances where you're working with external resources like from where the list to sort comes from. Commented Nov 15, 2016 at 18:49