git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v7 4/5] dir_iterator: refactor state machine model

From
Daniel Ferreira (theiostream) <bnmvco@gmail.com>
Date
Apr 3, 2017, 18:03 UTC
Message-ID
<CAEA2_R+EBbrD1rbcrP598AKJAEZDZfGY-ED8g+ehgAaL9tLG8A@mail.gmail.com>
In-Reply-To
<76c92397-8e15-b2fb-432f-0ae3d987ffa8@alum.mit.edu>
On Mon, Apr 3, 2017 at 12:36 AM, Michael Haggerty <mhagger@alum.mit.edu> wrote:
Show 5 quoted lines
> As far as I can tell, you got the logic in this complicated big loop
> correct on the first try (well, if we ignore v6 :-) ), even as you added
> new features. I think that's good evidence that the new structure is
> more comprehensible than the old, plus the new tests probably helped.
> That's a big win!
Thanks for ignoring v6 ;)

Another gain is that the other proposed features (only iterate over directories, do not recurse into subdirectories) are also quite easy to add with this new structure.

> It's not ideal that the test code depends on the numerical values of the
> flag constants, and it makes the tests harder to understand. It would be
> better if this program were to accept options like `--pre-order`,
> `--post-order`, etc., as I suggested in an earlier round of review.
Although it does make tests harder to understand, if we were to
specify how to iterate with human-readable flags we'd add the getopt()
+ flag configuration overhead to this helper program to be able to
handle all cases properly. Additionally, new flags added to
dir_iterator would have to edit the test program as well, generating
extra work.

I personally think that the string describing the test in the script is enough to explain what the flag-as-argument is doing for the sake of readability. The only gain I see in your suggestion is that we avoid the programmer committing errors calculating the flag by hand when writing the test.

That said, I'd appreciate some more thought on this.
> Michael
>

Thanks for the review. I agree with all other points and I'll address them in a next series.

Previous: Michael HaggertyNext: Michael Haggerty
Message 10 of 13 in “[GSoC] remove_subtree(): reimplement using iterators”
  1. 0/5 [GSoC] remove_subtree(): reimplement using iteratorsDaniel Ferreira, Apr 2, 2017
  2. 1/5 dir_iterator: add tests for dir_iterator APIDaniel Ferreira, Apr 2, 2017
  3. Stefan BellerApr 3, 2017
  4. 2/5 remove_subtree(): test removing nested directoriesDaniel Ferreira, Apr 2, 2017
  5. Stefan BellerApr 3, 2017
  6. 3/5 dir_iterator: add helpers to dir_iterator_advanceDaniel Ferreira, Apr 2, 2017
  7. Stefan BellerApr 3, 2017
  8. 4/5 dir_iterator: refactor state machine modelDaniel Ferreira, Apr 2, 2017
  9. Michael HaggertyApr 3, 2017
  10. Daniel Ferreira (theiostream)Apr 3, 2017
  11. Michael HaggertyApr 4, 2017
  12. 5/5 remove_subtree(): reimplement using iteratorsDaniel Ferreira, Apr 2, 2017
  13. Michael HaggertyApr 3, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.