Publication Date

Spring 2021

Degree Type

Master's Project

Degree Name

Master of Science in Computer Science (MSCS)


Computer Science

First Advisor

Thomas Austin

Second Advisor

Chris Pollett

Third Advisor

Mike Wu


design by contract, rule4j, jContractor, JML, Contract4j


Design by Contract is a software development methodology based on the idea of having contracts between two software components. Programming contracts are invariants specified as pre-conditions and post-conditions. The client component must ensure that all the pre-conditions are satisfied before calling the server component. The server component must guarantee the post-conditions are met before the call returns to the client component. Current work in Design by Contract in Java focuses on writing shorthand contracts using annotations that are processed serially.

Modern software systems require a lot of business rules validations on complicated domain objects. Often, such validations are in the form of a chain of independent tasks that need to be validated one after another. These tasks are computation-intensive and often involve numerous database calls and API calls over the web.

This paper presents a validation rule engine framework, Rule4j to facilitate writing such business rules with the help of programming contracts in Java. The contracts are organized in a hierarchy similar to the Racket programming language. The programmer can specify the business rules in the form of a series of higher-order contracts that form a chain. These chains of contracts are validated concurrently and asynchronously to present a final validation result to the programmer. A sample scenario of trade execution is used to demonstrate the performance gain and maintainability of the framework. The experiments conducted show that validations executed using Rule4J run four times faster than the traditional approach. A clear separation of business logic and business validations for the trade execution scenario was achieved using Rule4J.