Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Takeaway (2) #143

Open
bpbond opened this issue Feb 11, 2020 · 0 comments
Open

Takeaway (2) #143

bpbond opened this issue Feb 11, 2020 · 0 comments
Assignees

Comments

@bpbond
Copy link
Owner

bpbond commented Feb 11, 2020

When you have a minute, please take a look at b664ee0.

The parse_8100A_file() basically looked like this:

parse_8100A_file <- function(file) {
  determine how many records there are in the file
  loop through them {
    parse each record
  }
  return(results)
}

This made the function overly long, and the "parse each record" part really hard to test. In the commit above I pulled it out, so the file now looks like this:

parse_8100A_record <- function(record_text) {
  parse the record_text
}

parse_8100A_file <- function(file) {
  determine how many records there are in the file
  loop through them {
    record <- isolate_record_text
    results <- results + parse_8100A_record(record)
  }
  return(results)
}

Because it's broken apart, the parsing code becomes MUCH easier to test--which we now do extensively!

That's it, close when ready, just wanted to make the point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants