Friday, May 25, 2007

UML rules!

Currently I'm updating the white paper Business Rules in ADF BC. Doing so it occurred to me that there are still many questions to answer what to do when you want to record business rules in UML. With this posting I will share some of my idea's. JDeveloper 10.1.3 will be my tool and ADF BC4J the targeted persistence layer, but I expect the idea's to more generic and also applicable to EJB 3.0 and POJO's for that matter.

In "the old days" when we were young and still using the function hieararchy diagrammer, business rules were either an intrinsic part of the entity relationship diagram or recorded in function descriptions. As this sometimes resulted in the same business rule being recorded more than once (in different functions) and too often in an inconsistent way, we found it to be a neat idea to record them explicitly, that is as functions of their own, and link them to the functions they applied to. This has been a very succesful approach for quite a few years.

At the same time UML arrived as the modeling language for object-oriented analysis and design, and more recently BPMN for business process modeling. As I have never come upon any information system for which there were no business rules whatsoever, you can imagine that it was quite a shock for me to discover that there was no similar thing in place for UML at that time. Of course, a UML class diagram as such allows for expressing more business rules than an entity relationship diagram, but that covers only part of it, doesn't it? As far as the rest is concerned, we were kind of back to square one, meaning that we had to record business rules as part of use cases, for example. The BPMN specification even explicitly excludes business rules from their scope, so what do you do when using BPM?

Some improvements have arrived since the beginning of UML. At some point (not sure since when) constraints have been added (as a stereotype). Also OCL has emerged as a formal language to capture business rules. You can use OCL to record the business rule in a constraint. I don't know about you, but I still have to meet the first person that speaks OCL, let alone the kind of persons we call customers. So in most cases I expect constraints to be recorded using some natural language.

Now let's asume you are using UML to capture functional requirements. Business rules can be found during any stage, for example while doing use case modeling. When starting to create use cases it perfectly makes sense to record rules as part of that. Use cases have some properties that can be used for recording business rules, being pre-conditions and post-conditions. Pre-conditions must be met before the use case can be executed. A typical example would be "the user must be logged on", but could also be something like "the user must be a manager to view detailed employee information".

Post-conditions can be devided in minimal guarantees and success guarantees. Minimal guarantees indicate what must hold true when none of scenarios of the use case have finished successfully. A success guarantee describes a succesfull execution of the use case. Examples of success guarantees are:
  • The employee information has been recorded successfully
  • A change of the employee salary must have been logged
  • When the customer has boarded 15 times or more on a flight, its frequent flyer status must be set to silver elite.
Then there are so-called invariants, being conditions that always should hold true (before, during and after execution of any use case). Examples would be
  • End date must be on or after begin date
  • There cannot be a non-vegetarian dish in a vegetarian dinner.
Your use case template might not have a property called invariants. But hey, it's your use case, so why not add it?

By now you might wonder how to deal with the problem I pointed out at the beginning, being that you captured the same business rule more than once for different use cases. You might also find yourself recording business rules that relate to each other, or even contradict. Don't worry to much about that in the beginning (using the Unified Process that would be while doing Requirements Modeling). Just record the business rules when and where you find them. You only risk a confused customer when you start record business rules as artifacts on their own.

During some next iteration, you detail the use cases. By that time you might have a class model or will start to create one (using the Unified Process that would be during Requirements Analysis). At this point it makes sense to pull business rules out of the use cases and into constraints. Doing so you are able to remove duplications, and inconsistencies.

If your tool supports publishing use cases together with the artifacts linked to that (like classes and constraints ), you might consider to remove the business rules from the use case to prevent duplication and inconsistencies.

Using JDeveloper you normally add constraints to UML class diagrams and link them to the classes they relate to. But you can also include them in use case diagrams and link them to use cases. Finally, you can link related business rules together, which is convenient when you want to decompose business rules.

Having done all this you are not only able to track what rules apply to what classes but also to what use cases. Handy for example for testing purposes.

Finally, you can include the same contraints in (for example) ADF Business Component diagrams, link them to entity objects, classify them or whatever fancy stuff you like to do. Check out the new version of the Business Rules in ADF BC for ideas about classifying business rules when using BC4J. I will let you know when it get's published.

Got to stop here folks. A long and sunny weekend just knoked at my door, and I intend to open ...

11 comments:

jwbroek said...

Hey Jan. Where can we find this whitepaper? :-)

Jan Kettenis said...

The new one is yet to come. After I finished with it, I suppose it will be reviewed. I will let you know where to find, but you can also monitor the JHeadstart blog.

Mashood said...

Hi Jan,

Do you have any experience with Oracle Headstart? We are looking for somone who can impart training.

Please let me know your mail id so that I can write to you in detail about our requirements.

Regards,

Mashood

Jan Kettenis said...

I do but that's a long, long time ago (IT-wise spoken) and personally I cannot help you (anymore). It used to be on the Oracle University list of offered trainings.

What I would suggest is that you contact your local Oracle representative and ask if they can help you with this.

Anonymous said...

British tennis ace Andy Murray can expect a massive income injection after joining the same wow po management group that handles the likes wow or of David Beckham and Cristiano Ronaldo.

Simon Fuller's 19 Entertainment, wow geld partnered with CAA Sports, signed world number four LOTR Gold Murray and doubles-playing brother Jamie for representation across all their on and off court activity from LOTR gold March 2009.

"Jamie and I buy Warhammer gold/a> feel we've made big progress in the last couple of years on court," 21-year-old 2008 U.S. Open runner-up Andy said on his Web site.

"It's important that we have the very best team around us to take care of business while buy Warhammer gold we concentrate 100% on our tennis. Warhammer gold So this is a fantastic opportunity for us to work with buy Warhammer gold Simon Fuller, 19 and CAA Sports.

"We now have an Warhammer gold unbeatable combination of representatives buy Warhammer gold with world-class stature and experience, and Warhammer gold we are really excited by what we can achieve buy Warhammer gold together".

Fuller's company, which Warhammer gold is run from London, New York and LA, wow gold has partnered with CAA Sports, and already represents world of warcraft gold the world No. 3 Novak Djokovic.

American Idol creator Fuller buy wow gold commented: "I am very cheap wow gold excited to be working with Andy and Jamie, wow power leveling two of the brightest British wow powerleveling talents in global sports.

"Their determination dofus kamas to succeed has become a kamas dofus trademark in their game and their progress as professional Lord of the Rings Online Gold sportsmen has taken them to the LOTRO Gold top in world tennis.

"19's innovative LOTR Gold partnership with CAA Sports will provide them fly for fun penya with an unparalleled level of flyff penya global support".

Anonymous said...

I like a game which needs to use runescape gold, when you do not buy runescape, you must borrowrs gold from friends, or you get runescape money. If you getcheap rs gold, you can continue this game.

Anonymous said...

runescape moneyis your number one spot for all your runescape gold help you may ever need. We have a complete database of tons of quest guides, city guides, runescape gold
...

Anonymous said...

Once I played stoneage2, I did not know how to get strong, someone told me that you must have stoneage2 Gold. He gave me some stoneage 2 Gold, he said that I could buy stoneage2 money, but I did not have money, then I played it all my spare time. From then on, I got some buy stoneage2 Gold, if I did not continue to play it, I can sell stoneage 2 money to anyone who want.

Once I played flyff, I did not know how to get strong, someone told me that you must have flyff penya. He gave me some flyff money, he said that I could buy flyff penya, but I did not have money, then I played it all my spare time. From then on, I got some flyff gold, if I did not continue to play it, I can sell cheap penya to anyone who want.

World of Warcraft Gold Guides said...

good post :)

Anonymous said...

This is really a good article,I like it very much.


wow goldcheap wow goldwow

gold
buy wow goldwow gold
cheap wow goldbuy wow gold
World of Warcraft goldcheap World of Warcraft gold
World of Warcraft goldbuy World of Warcraft gold
World of Warcraft goldcheap World of Warcraft gold
buy World of Warcraft goldflyff

penya
cheap flyff penyaflyff penyabuy

flyff penya
flyff penyacheap

flyff penya
buy flyff penyaflyff

penya
flyff penyametin2 yangcheap metin2 yangmetin2

yang
buy metin2 yangmetin2 yangcheap flyff penya
buy metin2 yangmetin2 yangluna goldcheap luna gold
luna goldbuy luna

gold
luna goldcheap luna gold
buy luna goldluna gold<a

href=h

site said...

I consider everyone must read this.