# Rules Your Users Write

An online store's marketing team wants to write its own coupon rules, like "orders over $50 with a shoe in the cart", without asking a developer every time.

Updated: November 17, 2026

## [A Little Language](https://www.ask-codey.com/courses/design-patterns/topics/dp-a-little-language)

1. [Interpreter: A Little Language for Rules](https://www.ask-codey.com/lessons/dp-interpreter) (Freelancer): When business rules change every week and live in code as one if per rule, every new rule waits for a developer; the Interpreter pattern turns each rule into a tree of small pieces (a check, an and, an or, a not) that each answer one question, so a new rule is data, not code.

## [New Jobs for Every Kind of Thing](https://www.ask-codey.com/courses/design-patterns/topics/dp-new-jobs-for-every-kind-of-thing)

1. [Visitor: New Jobs Without Touching Every Class](https://www.ask-codey.com/lessons/dp-visitor) (Freelancer): When every new job on a tree of objects (describe it, count it, check it) means a new method in every class of the tree, each job ends up scattered across all of them; the Visitor pattern puts each job in one object with a method for each kind of piece, so a new job is one new class and the pieces never change.

## [Exercise: The Coupon Rules](https://www.ask-codey.com/courses/design-patterns/topics/exercise-dp-coupon-rules)

1. [Exercise: The Coupon Rules](https://www.ask-codey.com/lessons/exercise-dp-coupon-rules) (Freelancer): Take a ticket from Trailhead Outfitters' marketing team: they want to build their own coupon rules on an admin screen and read each rule in words. Change the working coupon code so any rule built from the screen's pieces can be checked and described, with the tests green throughout.

Source: https://www.ask-codey.com/courses/design-patterns/chapters/dp-user-rules
