Skip to end of metadata
Go to start of metadata

In his Tutorial on Good Lisp Programming Style (which all developers should read, regardless of whether they like Lisp or not), Peter Norvig notes that most algorithms are a combination of the following:

  • Searching
  • Sorting
  • Filtering
  • Mapping
  • Combining
  • Counting

Java's syntactic and library support for these components tends to cause the above concerns to be mixed with each other, with other concerns, and with low-level implementation details. This means that the code is cluttered, verbose and does not express intent very well.

Also, as a consequence of this mixing of concerns, unit testing is more difficult than necessary and often less robust against changes to implementation than it should be.

Jedi aims to repair this. It does so by providing a library of routines: filtering, iteration, conversion from one collection type to another, first order logic functions, etc. It makes extensive use of higher order functions and closures (also known as 'blocks' or 'lambdas' - if you are unsure what these things are, you have almost certainly used instances of them, such as 'listeners' in AWT / Swing, commands or actions in Struts / Webwork, or any 'callback' mechanism).

The problem with closures in Java is that, while they really represent functions, they must be presented as objects. Since methods / functions are not first class objects in Java, any closure must be 'wrapped' in an object, which means creating a class, either named or anonymous. Jedi helps with this by providing annotations which will generate the necessary code.

The generated code supports unit testing by providing several different ways to inject dependencies. You can therefore select the mechanism which supports your style of programming and testing.

 JEDI License

Jedi is released under the MIT license.


Join the Google Group Jedilib

  • No labels