A DSL With Instaparse For The Role Based Security Project
See Bitbucket : simple-auth-dsl
A DSL experiment for the simple-auth project.
Why?
I want to be able to express business logic in a text form. I think a DSL might be used to capture the operations of business logic in a testable form.
There maybe several advantages in doing this :
- The stakeholders can operate the business logic in its simplest form and can confirm that the logic captures the rules that they have to deal with.
- Stakeholders can oversee and advise as the language is developed.
- A DSL is more precise than a mountain of pictures of class in UML
- The DSL can form the first set of integration tests verifying that the system performs the base set of required operations.
- A DSL would allow batches of operations to be run using business terminology instead of unix shell or programming languages.
Its possible that a DSL would provide a good basis for defining increments in an agile process. Instead of creating stories, create a new phrase in the DSL. Perhaps this would work best for high level use cases.
Having worked on many enterprise scale java systems in the past a simple observation can be made. Each of the systems could have been operated without the UIs.
When a person is learning to use a system, the UI is very helpful. It shows (or it should show) very clearly the current state of the work and what effect making a change will have on that state.
Once an operator is familiar with the operation, constant precise mouse operations just slow the operator down. Indeed, an expert in the business logic would be able to get their job done a lot quicker and with a lot less wrist pain if the mouse could be avoided, or at least used less.
A DSL would be able to form the basis of a smart terminal, where options, auto completion and real time validation assist the user.
The question is will it work on a small scale application like the simple-auth project? This project attempts to find out.
Expected example operations :
ADD USER FIRSTNAME Fred LASTNAME Smith PASSWORD password -> user-id
ADD ROLE system-admin -> system-admin-role-id
ADD SERVICE list-users -> list-users-service-id
ADD USER TO ROLE system-admin -> list of user ids for users in role system-admin
ADD SERVICE service-id TO ROLE system-admin
The DSL
This project uses instaparse and BNF to create a simple grammer to operate the simple-auth service via its web interface using a command processing terminal. I might even build an admin ui on top of it, and as a complememt to try and show the point above about speed and efficiency for experienced users.