Business Rules Engines are a curious thing. For years they've been promising to ease the burden of writing and maintaining business logic, yet they never quite seem to live up to the promise. Want to give one a try? Let's have a look at a prominent Open Source BRE (Drools) as guided by this book from Packt.
The book starts out simply enough, with the first chapter introducing the idea of a BRE and the second covering rule authoring basics. From there, the author launches into building a banking application.
Chapter 3 is the 'Validation' chapter. This is a natural strong suit for a BRE, as they favor 'if/then' (or, as this author writes, 'when/then' logic). The author does a good job of introducing necessary parts of the Drools infrastructure, i.e. the 'rule context' which is useful in taking action when some condition exists.
Chapter 4 is about data transformation, it's not a far leap from Chapter 3. I think this was somewhat imaginitive on the author's part, as XSLT or a tool like Smooks tends is probably a better choice for transformation than a BRE would be. This book is all about Drools, though, so it makes more sense to do it this way.
Chapter 5 is the 'DSL' chapter. Rules tend to look a little awkward to coders unaccustomed to seeing them. A good example might look like this:
when
$customer : Customer (balance <>
then
$customer.setMinBalanceWarning();
warning (kcontext)
end
Instead of dealing with that kind of stuff, it's possible for some rules (if they fit a pattern) to be written something like this:
when
There is a Customer with a balance less than $200.00
then
Set the Minimum Balance Warning
Report this
end
Isn't that cool? It's really not all that mysterious, chapter 5 shows you how to do it. Warning: When managers see BRE marketing presentations, they sometimes watch something like this demonstrated and get all kinds of ideas about firing all the programmers and replacing them with business analysts. Rest assured, there is a programmer behind it all. (And a very skilled programmer at that. But this is for the rule practitioner to see....)
Chapter 6 covers stateful sessions, something that can be handy when your application doesn't experience big swings in the data it's crunching on. The author does his usual good job of providing an implementation, then some tests to prove the code. Once again, technical tidbits are introduced to the reader as they are needed.
Chapter 7 is about Complex Event Processing, somewhat a hot topic in today's Developer landscape. It's an interesting use case for Drools, so I was glad to see it.
Chapter 8 covers 'Drools Flow', which is one of the ways you can influence the order in which your rules are executed. To a garden-variety Java coder, this might seem like a strange statement-- how can you NOT influence the order in which your rules are executed? But that's the BRE way, and the author shows you one way to productively manage this 'feature' of the BRE.
Chapter 9 builds the Sample Application, which is the app that houses all the work done previously. It suffers a little scope creep, as the reader is expected to enclose their Drools work in Spring, Tomcat, etc. but I expect this won't be too much to ask of the type of reader who picks up this book.
The next chapter is about testing, always something nice to understand in whatever language or framework you're dealing with. Chapter 11 follows, that one covers integration issues. (Roughly, how do you take all your useful Drools code and apply it somewhere?) It's another nice thing to have spelled out.
The final chapter is on performance. It's a little funny because this final chapter enlightens the reader on the inner workings of the rule engine, something you might expect to see in the front of the book rather than the back. But it's good stuff, so I'm glad it was included.
There are 3 appendices, focused on helping with preparations for running the code the book provides.
So, what's the verdict? Here are the things I like:
- Gives some expert insights into how to write an application with a BRE
- Covers lots of the different facets offered by Drools
- Provides good explanations for technical tid-bits
Now for some dis-likes:
- Not enough guidance on best practices. Some are here, buried in the text, but you have to realize what you're looking at. The market really cries out for a book that explicitly provides these.
- Probably not enough to get a BRE newbie off the ground. Combined with the Drools user doc ('Cheese Shop'!) it may be enough.
- The author does a good job of using Drools for several purposes, but does not give the reader much guidance on when it really is smart to use a BRE and when it isn't. (There are plenty of places where it isn't-- I guess it's up to you to decide!)
All things considered, I liked the book. Next time I'm into Drools, I'm certain it'll be by my side!
The book can be found here.
..........
if
you liked this article
then
come back again another time!
end
Rick
1 comment:
Very nice and impressive article you have posted. Its very helpful, i have read and bookmark this site and will recommend it to more other peoples.
Post a Comment