Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
android notif: Parse things at a "crunchy shell", step 1 of N.
We're going to refactor this code into the "crunchy shell, soft center" pattern, where * All parsing of messy data-from-the-network happens at the edge, as soon as possible. * The parsing logic at the edge constructs new, inward-facing data structures from the messy data it gets. It meticulously ensures that the data it produces has the expected format. Where the messy input does something unexpected that we aren't prepared to cleanly handle, the input is rejected at the edge. * All the application code on the inside deals only with the nice, well-formatted data produced by the parsing logic at the edge. As a result it needs many fewer boring checks for null, for strings that should parse as integers but don't, etc., etc. The real application logic it's expressing is easier to read, and it's less prone to bugs. * The metaphor: the edge is "crunchy" with parsing and validation, protecting the inside so it can safely be "soft". * In particular, when data comes in that doesn't match expectations, a program without a "crunchy shell" will run into that fact somewhere deep inside application code. It's likely to be missing any logic there to deal with the situation, and then to crash; if it does handle it, it may have already half-processed the data, making it too late to cleanly ignore. When bad data is caught by a "crunchy shell", it gets cleanly ignored or rejected. We'll go about this in incremental, individually-understandable steps over a series of commits. This commit gives the "shell" its first small bit of "crunch": we parse out one required field, `recipient_type`. Most of the commit is in adding a few lines of shared infrastructure that will be re-used as we move more parsing to the "shell".
- Loading branch information