Motif is a Java library that helps you to compose simple units of program logic, which together forms the actual behavior in your application. Most of the concepts in Motif is inspired from functional programming, but what’s important is that it is just plain old Java, with no extra bells and whistles, though it might look a little unfamiliar if you are mostly accustomed to idiomatic Java code.

The motivation for this library is not to transform Java into a functional language - that would neither be possible nor practical. The goal is to enable Java programmers to express common, and often errorprone, imperative idioms (for, while, if-else, null-checks, etc) in a more safe way, where you will get help from the compiler to compose the correct logic. If using Motif inspires you to learn more about functional programming, that is awesome, but it is not a goal of Motif to simulate or replace a real functional programming langugage. Java is an object-oriented imperative language, and Motif only seeks to provide programming constructs to aid with the correctness of your objects’ behavior.

Getting Motif

Include the following declaration in your POM to start using motif in your project:

<dependency>
    <groupId>com.github.runeflobakk</groupId>
    <artifactId>motif</artifactId>
    <version>0.8</version>
</dependency>

Descriptions for other build tools can be found on this page

Composing motifs

The name ‘Motif’ was inspired from music, where a motif is a recognizable and recurring small musical fragment to form complete compositions from.

Go here to learn how to use Motif.

Back to top

Version: 0.8. Last Published: 2016-03-02.

Reflow Maven skin by Andrius Velykis.