GoRuCo talk: Business Natural Language

Presented by Jay Fields

  • Business Natural Language (BNL) is Domain Specific Language (DSL)
  • Traditional feedback loop: Business <- Developer -> QA
  • With DSLs: Business stakeholders update logic

Benefits

  • Managers—Improve efficiency
  • Developers—Technical decisions not business decisions
  • Business—Reduce time to market

(BNL == BSL) # => false

So?

  • Concise or verbose?
    • Less technical users might need more verbose DSL
  • Who’s the author?

“DSL” is too general

  • BNL is a subset of DSL
  • BNL characteristics differ from general DSL characteristics

The Difference

  • Written as natural language
  • Written by business people
    • Subject matter experts

Example specification

  • “Award 2 points if the fare class is A, C, D, J, Z”
  • account.award 2.points if [A,C,D,J,Z].include?(fare)

How?

  • Use preprocessor…
  • account.instance_eval removes need for account.
  • Use gsub to downcase fares (to avoid them being read as constants)
  • Fixnum.point does nothing. It’s syntax sugar.
  • Remove the word “class”. Not needed by Ruby.
  • gsub to add brackets around a list
  • gsub to remove words without business meaning (i.e. “the”)

Result: Specification == Code

  • Specification is code
  • Specification is readable documentation

Descriptive and maintainable phrases (DAMP)

  • More verbose, but verbosity makes them maintainable.
  • Since the business users control the logic, it’s easier to maintain

Do not sacrifice readability for conciseness

  • Staff changes
  • Other people will eventually need to read it

Who is the user?

  • Who are you designing for?
  • Verbose phrases are not strictly necessary but help subject matter expert maintain the language

Training

  • BNL has room for improvement if it requires any training to understand
  • Make your language fit the requirements instead of the requirements fitting your language
Applications can be built 80% faster with DSL
  • Actually, that’s bullshit.
  • But… “A change that used to take 3-4 days now takes 10 minutes.”

Why not offload non-interesting parts of the application to people who actually care about the rules?

Getting it to execute

  • BusinessLogic returns the rules from the DB
  • eval it once when we change the method, then save it as a method
  • One run eval again when rules change

Deployment?

  • New workflow: Business <> Approver <> Production
  • Developer not in the process
  • Flag scripts as “active”, expire old scripts

Programmers: Are you out of a job?

  • Absolutely not
  • Still need:
    • Language workbench
    • Workflow
    • Syntax checking
    • Test environment

Syntax checking

  • Very important
  • Needed for subject matter experts
  • Usually need contextual recommendations (i.e. “when the far” => “Did you mean ‘fare flass’?”)
  • Can be done with AJAX

Commercial language workbenches

  • MPS – JetBrains
    • Beta, but usable
    • Fowler has “hello world” examples
  • Intentional—Not available

Another example—Employee compensation

  • Verbose, but everyone can read it

When is BNL a bad choice?

  • Broad, unrelated project
  • Not necessary for programmers

How to decide?

  • Who is the author?
  • How frequently will the logic change?

How is this relevant to Ruby?

  • Not required, but easier than in Java or others
  • Need eval

More information

3 Responses to “GoRuCo talk: Business Natural Language”

  1. # Lyle Says:

    Bryan, this one sounds like an interesting talk—what did you think of it? Do you know if anyone was videotaping the GoRuCo talks and when (if) those videos will be available online?

  2. # Eliot Says:

    Thanks for blogging these so completely and efficiently.

  3. # Bryan Helmkamp Says:

    Lyle—I’m intrigued by the concept Jay presented. I’m a big fan of DSLs, but I’m a little worried that this method might lead to trouble because although it might appear to the user that the system can understand their intent from natural language, that is not truly the case.

    All the talks at GoRuCo were recorded by Google’s AV team, and they should be available on Google Video soon. I’ll post an update when this happens.

    Eliot—You’re welcome.