James Mead by James Mead

Week 371

Smart Answers

Automatic detection of possible next nodes

When we started work on the project, some (but not all) smart answer flows were using calls to next_node_if with various predicates. We decided that it would simplify the code and maintenance of the flows if we standardised on a single approach.

We didn’t think the custom predicate style was very readable and we felt that it would be unfamiliar to most developers. Also we might’ve needed to extend the predicate style in order to cater for all flows. So we decided to standardise on the non-predicate style i.e. passing in a block of Ruby code to a call to next_node for each question.

In making this change, in order to retain the ability to visualise the flow, we had to explicitly specify a list of possible return values for each next_node block. This felt like a type of duplication and made the code look overly verbose.

So this week I started spiking on ways to automatically detect the possible return values of a next_node block. I had some success using a combination of method_source to obtain the source code of the block, and parser to convert the source code to an AST and filter out the relevant AST nodes.

Refactoring marriage-abroad

Chris continued with his mission to refactor the marriage-abroad flow. He’s trying to better separate the concerns by moving policy logic out of the flow and into a separate class which is more easily testable.

This week he merged a couple of pull requests:

And started work on another:

GFR

As usual this was mostly admin-related work:

  • I wrote up some notes on the meeting I had at GDS the previous week.

  • We finally received a belated refund relating to our storage unit at Urban Locker and Chris sorted out the related book-keeping in FreeAgent.

  • Our Harmonia task for paying ourselves had grown considerably over the years and we decided to split it up into a number of smaller tasks. Chris finished off doing this during the week.

  • Our staging date for pension auto-enrolment is 1st April and so Chris double-checked that we’re compliant with the legislation.

That’s it for this week. Until next time.

– James

If you have any feedback on this article, please get in touch!

Historical comments can be found here.

Recent