Sunday 13th March, 2016
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
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
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
block. This felt like a type of duplication and made the code look overly
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.
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:
- Move logic from country_of_ceremony question to MarriageAbroadCalculator
- Remove calculate blocks from country_of_ceremony question in marriage-abroad
And started work on another:
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.