Introduce a DSL
Domain specific languages (DSLs) are tiny, specific languages written in a generic programming language. If you know where to look, Elixir embeds DSLs everywhere. ExUnit uses a DSL to build unit tests. Ecto Query uses a DSL to express queries and schemas. Phoenix uses a DSL to build a router table.
If you think about it, our code is building a tiny DSL that expresses Roman numerals. Some of the work is defining an API that our consumers can use. Other pieces of the problem involve packaging up our DSL in a convenient package our customers can consume.
Our Roman API already has some convenient functions that return a map of Roman numerals and an API to convert singles. It would be nice to introduce a feature that allows users to ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access