Monday, July 31, 2006


01 - Introduction
02 - The Problem
03 - The Solution
04 - DAMP BNLs
05 - Multiple Contexts

DRY code, DAMP Business Natural Languages

Don't Repeat Yourself (DRY) is a best practice in software development. Specifying behavior once and only once is the essence of the DRY rule. When you follow this rule the maintainability of the software is increases. The rule helps ensure that if you are required to make a change you can be sure that you will only need to change the software in one location. The benefits of this rule should be quite obvious; however, does it also apply to Business Natural Languages?

Based on my experience I believe that the DRY rule does not apply to Business Natural Languages. A major reason for using a Business Natural Language is to separate the business logic from the complexities of the under-lying system. When using a Business Natural Language, business users who are the most familiar with the domain can maintain the business logic. To a business user, a Business Natural Language should be no different than a group of phrases that describe the rules for running the business correctly.

A well-designed Business Natural Language will appear as Descriptive And Meaningful Phrases (DAMP).

In 'The Solution' I used the following business logic to calculate Jackie Johnson's bonus:

apply bonus of the total profit times one percent if the current month is equal to february
apply bonus of the drug profit times two percent if the current month is equal to february

In the Verbosity module I defined a bubble method that created methods for each member of the list passed to bubble. Each method that was defined by bubble took one value and returned the same exact value. This allowed the Business Natural Language to be verbose enough that not every word was required to have meaning. In fact 'than', 'is', 'profit', 'the', 'to', 'of', and 'bonus' are all bubble methods. Without bubble methods the business logic would read:

apply total times one percent if current month equal february
apply drug times two percent if current month equal february

The new logic can be considered more DRY; however, much of the readability has been lost at the expense of removing the some of the duplication. You should not trade readability for conciseness when designing Business Natural Languages.

As businesses change their software requires change. If software can be understood and altered by subject matter experts the business can be more responsive to change. Business Natural Languages facilitate empowering subject matter experts by using a meaningful syntax to express business logic. This meaningful syntax often contains words that do not carry programmatic value; however, they increase the overall readability of the phrase. Therefore, the 'bubble' words carry maintainability value for the subject matter experts. If the 'bubble' words are removed the logic becomes less maintainable.

It is also important to note that employees often change roles within an organization. Because staffing does change, you should not design a Business Natural Language that sacrifices readability for conciseness simply because the current subject matter expert is able to comprehend the concise version. Instead, you should design the Business Natural Language to be easily understood by any subject matter expert placed in that role.

Some programmers object to 'bubble' words because they do not effect program execution. This is a fairly common thought because programmers are still thinking in terms of 'what will make the system work' instead of trying to solve a more valuable question: How can I empower a subject matter expert to make the system work? When you begin to think in these terms you see that 'the' may be equivalent to white space to the computer; however, it's highly important to the subject matter expert who will need to continually understand and update the system.

Another concern is that 'bubble' words can confuse the subject matter expert because they have no meaning. The problem with this concern is that it assumes that the subject matter expert understands that the other words do have meaning. The 'bubble' words make much more sense when you understand that to a subject matter expert the entire phrase is important, not the individual words.

You could argue that you should allow any non-keyword to be interpreted as a 'bubble' word. There are technical issues associated with this; however, I think a more important issue to consider is that this will allow subject matter experts to write rules without following a pre-defined convention. The lack of convention could lead to decreased maintainability.

The main goal of a DAMP Business Natural Language is empowering subject matter experts by providing the most maintainable syntax available. A Business Natural Language clearly has room for improvement in the syntax if it requires training to understand. An ideal Business Natural Language contains phrases that are descriptive and meaningful enough that they require no explanation at all.

1 comment:

  1. Anonymous1:55 PM

    yeah I suppose readability is better than DRY...sigh :)


Note: Only a member of this blog may post a comment.