Language selection


Rules as Code, Part 2 (DDN2-V17)


This video (part 2 of 2) provides an insider's tour into a multi-departmental Rules as Code project, explores what was learned along the way, and looks at what it takes to run a similar project.

Duration: 00:04:38
Published: November 27, 2020
Type: Video

Now playing

Rules as Code, Part 2

Transcript | Watch on YouTube


Transcript: Rules as Code, Part 2

Rules as Code
Part 2 of 2
The discovery project

Hi, I am Scott, and I work at the Canada School of Public Service. Rules as Code is a promising concept and we feel like there is so much to learn on the topic.

To this end, we worked with a community of like-minded partners within the Government of Canada to explore the concept's potential and test how it could be put into practice. I'm excited to share what we learned along the way.

To demonstrate the process of drafting rules into code, we first decided on a regulation to test. Our team used employee entitlements to vacation pay, from sections 12 and 13 of the Canada Labour Standards Regulation.

First, we identified key concepts in the regulation and defined relationships between them, creating a concept model that helped us better understand the rules that we would code.

Next, we created a decision tree, by transforming the regulation into a series of yes or no questions. We worked with subject-matter experts to understand the intent of the regulation. We were then able to show how concepts like medical leave could affect vacation pay.

Finally, our private sector partner programmed the decision tree into computer code. This showed the potential of the exercise. From here, any application can be programmed to automatically connect and use this code… such as this proof of concept, built by our partner, that calculates vacation pay entitlements based on key variables entered.

While the code and prototype would require more work to be ready for deployment, they prove that applications can connect directly to the coded rules. As a result, the rules are more accessible, transparent and easier to maintain.

This just scratches the surface of how we can use encoded rules to offer greater value for Canadians!

Rules as Code – Lessons Learned

The most valuable part of our discovery project was learning as we worked through the process.

1) Best suited to… rulesets that can be quantified …. and that are prescriptive – Subjective rules will still need humans to interpret them

First, rules as code is better suited to rulesets that can be quantified and are prescriptive. Subjective rules - those that contain words like 'may' or 'could', will continue to need humans to read and interpret them.

2) Difficult but rewarding process… Need to understand rule and its intent/Legal interpretation is required/But important for accurate coding

Second, turning rules into computer code is not easy. This project showed the importance of fully understanding the rule and its intent. While clear and unambiguous language is ideal, some rules will require legal interpretation. This makes the process more difficult but it is a critical step to allow programmers to accurately encode the rules.

3) Current processes will need to adapt… Current process involves a limited group of subject-matter experts/lawyer/drafter/service designer/programmer

Finally, to move forward with rules as code, it is clear that current processes to draft rules would need to adapt. The current drafting process involves a limited group of subject matter experts and drafters. Our project showed that an effective way of developing rules is for multi-disciplinary teams of subject matter experts, drafters, service designers and programmers to co-design the rule using a user-centric approach. This brings a diverse range of ideas and perspectives, increases mutual understanding of policy decisions on service delivery and ensures everyone has an understanding of the needs of impacted people and systems.

Rules as Code – Moving Forward

This project allowed us to take an abstract concept and test what it would take to turn rules into code.

There are more questions to investigate – for example, we would be curious to know how rules could be drafted in code while being simultaneously (emphasize) drafted in English and French. We think the benefits of rules as code could be amplified if applied to a new rule.

Wherever we or others take this work, we look forward to continuing this ‘learning by doing' journey toward better rules for all Canadians.

Related links

Date modified: