2008 Apostila Oracle
2008 Apostila Oracle
7 Cases in which
you should adopt a DSL
If you are not sure DSLs are a good fit for you, you can write to me at
[email protected].
If you want to have a more in-depth discussion you can also schedule a
roadmap call, so we can talk about the specificity of your situation and
assess what is the best way to go.
2 of 18
DSL Checklist
3 of 18
DSL Checklist
1
Do your experts already use
a formal notation?
These must be the basis on which your experts decide and debate the
best course of action. For example:
If the answer is yes, the good news is that they are already using a DSL.
The problem is that they are using one that is only partially formal and
they are giving up the possibility of using tools to support them.
4 of 18
DSL Checklist
5 of 18
DSL Checklist
2
Is the real business value in
the knowledge of the
domain experts?
In many cases you sell software but what your customers are really
interested into is the knowledge contained in those systems. Chances
are, you are in the business of selling knowledge in a well-packaged
form.
For example, you are selling accounting software that apply the correct
calculation for every business need.
If the answer is yes, you want to make sure to isolate your domain
expertise in a way that can be reused over time. For instance, with a
DSL you can use the same business logic to power a web service or a
desktop application.
One customer I worked with created its own DSL over 20 years ago.
They captured their knowledge about accounting rules using that DSL.
Over time new technologies came and go, and they migrated the
tooling around the DSL, but the knowledge remained expressed in
that DSL. They never had to throw it away and start a new
6 of 18
DSL Checklist
7 of 18
DSL Checklist
3
Do you want to reduce the
time to train your experts?
How bad is when a domain expert leave your company? How much
effort and time you have to put in to bring a new hire up to speed?
By formalising the knowledge that your best people already have, you
can use a DSL both as a teaching tool and as a way to limit the
mistakes and the hand-holding of the new employees.
8 of 18
DSL Checklist
example if your company makes electronic toys, the DSL can have a
tutorial to explain the proper way to describe the toy. And if one of the
designer put a voice function with 10 different phrases, it can
automatically check that there is the proper amount of memory to
contain all the phrases.
9 of 18
DSL Checklist
4
Are communication or
coordination a bottleneck?
Have you evaluated the influence that poor communication has on it?
How much energy you have to put to make the information circulate
across different roles?
Yes, agile development could reduce this issue but not cancel it.
Developers have still to build a product and look for feedback only
after the fact. By adopting a DSL domain experts can participate in
using it or providing feedback as soon as it is written.
10 of 18
DSL Checklist
How do you think this affected development time? How this affected
the relation between developers and domain experts?
11 of 18
DSL Checklist
5
Are your domain experts
busy writing code?
You employ some domain experts that have some basic coding
knowledge and they write their own scripts. For example, they could
be scientists or mechanical engineers.
What is the problem with that? The problem is that is not the best
usage of their time, and given you probably spends a significant
amount of money for buying their time it makes that your problem.
The other things is that people who are not professional developers
but just code because they have to, do not produce the best code. Are
you pouring money to produce code that is unreliable? Code that has
poor quality?
If you are in this situation you could consider an alternative: you could
free some of the precious time of your workers by designing a DSL
that cater to their needs, and allow them to describe a problem in a
formal way. Typically productivity can be significantly increase (a 20x
increment in productivity due to the adoption of a DSL is not unheard
of).
12 of 18
DSL Checklist
In this particular case other benefits are also very relevant: they would
not spend their time programming but using a DSL to formalise their
thought. This would be arguably more enjoyable for many experts,
leading to less turnover. A very important aspect is quality: a DSL
typically permit to avoid entire categories of quality issues you have
when doing classical programming. You can design a language that
makes impossible to have memory leak, infinite loops or null pointer
exceptions. Most importantly it makes the code more understandable,
and this permits to root out many conceptual mistakes.
Let’s be honest: scientists who write code because they have to, are
not professional at writing code. They tend to produce code that is
hard to maintain, poorly written and they take a lot of time to write it.
13 of 18
DSL Checklist
6
Are there many departments
that must collaborate on the
same project?
14 of 18
DSL Checklist
15 of 18
DSL Checklist
7
Are there strong needs for
safety requirements?
16 of 18
DSL Checklist
Consider for example the case in which you write code to control
machinery. You could use the state machine paradigm: pressing
buttons or activating levers correspond to send an event to your state
machine, which will react in different ways depending on its state.
If you are using a DSL to describe your systems you could use solvers
to verify certain properties of you state machine: is there a possibility
for infinite loops? Are all states reachable? Are all events handled? You
can use static analysis on your high level language to root our vast
categories of problem. This give you absolute certainty about the fact
that your system has certain properties. And it gives you that for free. It
sounds a good deal to me.
17 of 18
DSL Checklist
What’s next?
If you have questions or doubts you can always look for more content
on my blog.
https://tomassetti.me/category/language-engineering/domain-
specific-languages
https://tomassetti.me/category/language-engineering
If you cannot find an answers write to me and I will try my best to help
you. You will find me at [email protected] .
If you think that a DSL will help your organization you can schedule a
roadmap call and we can figure out together what is the best course of
action.
18 of 18