About this Book – Jess in Action: Rule-Based Systems in Java

About this Book

This book was originally conceived in August 2001. As I write these words now in May 2003, I feel like I’ve stayed quite close to the original concept for the book. Then, as now, despite the still-growing prominence of rule-based systems in nearly every field of software development, the few available books on the topic were heavily theoretical and lacking in real-world examples. With this book, I set out to change that pattern. The book you’re holding is structured around a series of large, fully developed, and eminently practical examples of rule-based programming in Java.

This book can be used in several ways. First, it is a general introduction to rule-based systems. If you’ve never encountered rule-based systems before, you’ll want to read part 1 closely. This first section of the book introduces the concepts behind rule-based systems, discusses their applications, and shows some first examples of rule-based programs written with Jess. Part 1 also discusses what’s involved in adopting a rule-based solution at your company. Although the programming examples in later chapters use Jess as a vehicle, the concepts presented will transfer to other rule engines easily.

Second, this book is a programmer’s manual for the Jess rule language. Part 2 is part Jess language reference and part tutorial. It first introduces you to the language, and how the language is integrated with Java. Later chapters in this part discuss rules and working memory elements—the data that rules operate on. There’s also a chapter describing some of the theory behind Jess and what makes it run fast.

Finally, this is a cookbook for real rule-based systems. Parts 3 through 6 describe substantial, realistic software systems in enough detail to teach you how to develop similar systems on your own. Each part presents a rule-based system of increasing complexity, and also introduces new programming techniques:

  • Part 3 presents an information kiosk, the Tax Forms Advisor, that helps customers choose which income tax forms to bring home. You’ll learn how to collect expert knowledge and condense it into rules. The kiosk as presented has a simple text-based interface.
  • Part 4 is concerned with the development of the PC Repair Assistant, a help-desk application with a Swing-based graphical interface. This example builds on and extends some of the software infrastructure developed for the Tax Forms Advisor.
  • In Part 5, I’ll guide you through the development of the HVAC Controller, an intelligent climate-control system for a hypothetical office building. This part shows how rule-based systems can be interfaced to hardware. A special section written by Bob Orchard, developer of the FuzzyJ toolkit and the FuzzyJess extension for Jess, shows how the HVAC Controller can be enhanced by the use of fuzzy logic.
  • Part 6 is about web-based e-commerce solutions. This part presents a Recommendations Agent that analyzes a customer’s past and present purchases to recommend additional items of interest. The Recommendations Agent is embedded in a set of servlets and JavaServer Pages in the Tomcat servlet engine.
  • Part 7 is a little different. The two chapters in this last part cover various topics relevant to using rule-based systems in enterprise applications, including using XML as a rule language, and working with application servers, Enterprise Java Beans, and the J2EE environment.

The main text does not try to be an exhaustive guide to all of Jess; instead it concentrates on those features relevant to the example applications. The first two appendices provide some additional detail. Appendix A includes a description of each of the functions built into the Jess language, and appendix B presents the highlights of Jess’s Java APIs.

The development methodology used in this book emphasizes testing. Appendix C presents a simple automated testing framework that can be used to test Jess applications. The code for this framework is available from this book’s web site.

Who should read this book?

Because this book can be used in several different ways, it has several distinct possible audiences. Part 1 is an introduction to rule-based systems for any student of information technology, practitioners and management alike. The later parts of the book are aimed squarely at programmers. I’ve assumed an intermediate knowledge of the Java programming language throughout. Occasionally I explain a Java concept, but most of the time, I just imagine that you understand.

The audience I thought of most as I wrote are intermediate Java programmers with little or no exposure to rule-based systems, who are interested in getting that exposure.

This book is also suitable as a text for a university course on practical rule-based systems development. The course prerequisites should include a course on Java programming. The course content would include parts 1, 2, and 3 of the book, followed by either part 5 or part 6. Additional material could be used as time permits, of course.

Source code downloads

The code for all the major examples and applications in this book is available from the book’s web site, www.manning.com/friedman-hill. You can also download a special version of Jess from this web site.

Typographical conventions

This book includes listings of code in both the Jess and Java languages. It also contains transcripts of interactive sessions at the Jess prompt. All of these are set in monospace type. Keywords, function names, variable names, and symbols in any language are also set in monospace when they occur in the main text. It is generally clear from context whether I’m talking about Jess code or Java code, because the two don’t look much alike.

In the interactive session transcripts, the Jess prompt and things that you enter are all shown in normal monospace type, while responses printed by Jess are shown in italic.

In step-by-step examples, text that you are to type appears in bold.