You are about to read my first (and only) very minor complaint about OPA.  I apologize in advance to the OPA staff who have produced an otherwise exceptional (and I mean that) product.  The Oracle OPA consultants know their stuff.  The product is mature and adds actual business value.


I have been meaning to correct OPA example projects.  Some OPA examples show anti-patterns of OPA usage.  Then, I see these same anti-patterns by novice OPA developers who are making a lot of money off my clients.  Ouch!  I mean a few examples violate Jasmine's and other's best practices in gross fashion.  I already have issue with java/.net developers claiming to master OPA after a few classes and a few weeks of self-teaching, but it doesn't help if the OPA examples encourage poor OPA policy writing.


One project in particular bugged me tonight and I corrected a few problems with it in about 2-3 hours over a few beers.  Yeah, I am writing this buzzed.  My bad.


Actually, I would prefer to rewrite the example from scratch, but instead I opted to keep the interview almost exactly the same and only change the rule documents.


I did make a minor, minor adjustment to the interview.  I decided to have OPA only display relevant screens.  I couldn't let that one slide.  So sue me.


Which project "bugged me" tonight?  The EmployeeOrContractor example project makes several big errors and violates OPA best practices.  I attach an improved but not perfect modified version that does the same exact thing.


Fowler, what is wrong???  What is violated?


1) The project hides substantive rules in the interview screens (specifically in value lists). Don't believe me?

2) The project attributes do not reflect the interview questions on the screens meaning that ONLY the web interview screens make any sense.  Forget calling this project with a web service as you have to supply your own substantive scoring.

3) Screens continue to be invoked after a determination can be made.  That is a no-no in my book.

4) It won't scale, although I understand it is just an example.  The problem is that repeating values are not put into entities. If you have repeating values, put them into entities, especially if there is no source material that reads otherwise.  (My rule is to try to match the source material for the benefit of policy analysts.)

5) Shall I go on?  or maybe I attach a partially-corrected example.   See that attached.


In the end, this project could be a good demonstration of a helper calculator project if properly written.


This example interview should use some patterns in my mind that I will try to post about in the future.  One pattern is an OPA Scoring Pattern.


In the OPA Scoring Pattern, booleans provide pass/fail, but other attributes may need to be added together to pass a threshold.  I see that pattern all the time.  That pattern is actually what made me look at the example tonight. I wanted to double-check my approach and then banged my head against my desk.


In the pattern, first you ask some basic pass/fail questions.  In this example, they ask a poorly written question of "Is the person an apprentice, trainee, company director, labourer or trades assistant?"  I didn't change that question, because I wanted the screens to remain unchanged, but...


Once the pass/fail questions are asked, then interviews get into more "fuzzy" questions.  In this example, the "fuzzy" question start with "Degree of Control".  I left things as they are, but if I re-wrote the example I would allow for more possible answers from the business.


BTW, I also added test cases.  Every Oracle OPA provided example should have test cases, imho.


Maybe I had too many beers the last 3 hours???  Thoughts?


Disclaimer: I really, really do appreciate OPA and Oracle Staff.  I know them.  They constantly take time off to work with me and they are very clever and nice.  You only have to look at temporal reasoning and the natural language constructs to see how clever they are.  This will probably be my first, last, and only gripe. I am bothered by example projects that are not to the level of quality as the product itself (or the Oracle staff).


Can anyone tell I am feeling guilty about posting a negative that will be read by a group of people who are very nice and accommodating?  I should cut back on the beer.  Nah.