From d9c33455325188e669c00c6fb67e6121963eb939 Mon Sep 17 00:00:00 2001 From: baarkerlounger Date: Mon, 22 Nov 2021 16:22:32 +0000 Subject: [PATCH] Add ADR --- docs/adr/adr-011-form-oop-refactor.md | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 docs/adr/adr-011-form-oop-refactor.md diff --git a/docs/adr/adr-011-form-oop-refactor.md b/docs/adr/adr-011-form-oop-refactor.md new file mode 100644 index 000000000..d8d32321d --- /dev/null +++ b/docs/adr/adr-011-form-oop-refactor.md @@ -0,0 +1,10 @@ +### ADR - 011: Splitting the form parsing into objects + +Initially a single "Form" class handled the parsing of the form definition JSON as well as a lot of the logic around what different sections meant. This works fine but led to a lot of places in code where we're passing around arguments to determine whether a page or section should or shouldn't do something rather than being able to ask it directly. Refactoring this into smaller form domain object classes has several benefits: + +- It's easier to compare the form definition JSON to the code classes and reason about what fields can be passed and what effect they'll have +- It moves business logic out of the helpers and keeps them to just dealing with display logic +- It makes it easier to unit test form functionality, and group that into smaller chunks +- It allows for less passing of arguments. e.g. `page.routed_to?(case_log)` vs `form.was_page_routed_to?(page, case_log)` + +This abstraction is likely still not the best (the form vs case log split) but this seems like an improvement that can be iterated on.