Skip to content

Structure

JohnnyJayJay edited this page Mar 27, 2020 · 5 revisions

Project Overview

The project consists of multiple parts and user interfaces.

  • The core framework - A lightweight and simple framework where you implement commands using a java interface.

  • The bind framework - An aspect-oriented and declarative framework that is based on the core framework.

  • The compile API - A bridge between the core and higher-level abstractions like the bind framework. Unless you want to write an own framework on top of mela-command's core, it is not of major importance.

  • Provided bindings for the bind framework - A standard library of argument mappers and mapping interceptors.

  • A Guice package - Code that each module contributes to in order to make the usage of mela-command in combination with the dependency injection framework Guice very straight-forward.

Core

Core Framework Guide

The core framework is part of every mela-command project. It provides the basic interfaces and structures for any extension and further implementation and all other modules depend on it, but it can also be used directly.

It is simpler and more lightweight than the bind framework, because no additional processing happens before or after command execution. Instead, the arguments are passed in an unprocessed, yet wrapped state.

Main characteristics of the core framework:

  • Procedural Command Modeling

  • Focus on simple commands

  • Pure command execution, thus very fast

  • Lightweight

Use the core framework interface directly if your application is very small and its commands are simple, i.e. only have a low number of parameters and context-based checks & conditions.

Bind

Bind Framework Guide

The bind framework lets you write commands in a different way. It is aspect-oriented, meaning that command execution is divided into different aspects that all work independent of each other.

It also allows for a more declarative programming style (in the literal sense). Modeling commands, their restrictions and parameters works through method and parameter declaration. This makes commands easy to understand, modify and generally very concise, as only the actual command logic is directly associated with a command.

Main characteristics of the bind framework:

  • Aspect-Oriented Programming

  • Declarative Command Modeling

  • Complex commands are as easy to write as simple commands

  • Concision

Use the bind framework if you have many commands where you do the same things over and over again: parsing arguments, checking for certain conditions and handling exceptions in similar ways. Or use it as an alternative to direct interaction with the core framework, as the bind framework covers all of its capabilities.

Compile

The compile API is a bridge between the core and any custom framework built on top of it. It is part of the core module.

A compiler takes an object and creates a set of core commands based on it. The semantics of those transformations depend on the implementation. For example, compilers for the bind framework take an object and extract a core command for each command method.

The purpose of the compile API is thus to make the creation of own frameworks possible that use the core of mela-command.

Use and implement the compile API if neither the direct core nor the bind framework can provide the features and structures you need.

Provided

Documentation

The provided module provides a standard library for the bind framework, i.e. a set of commonly required mappers and interceptors.

This includes:

  • Mappers for String, primitive types, generic collections, arrays, maps and a few mela-command types

  • Interceptors for flag parameters, optional and default parameters, parameters deduced from context and some validation mechanisms

  • A Log interceptor that logs command executions using SLF4J (optional)

Use the provided bindings if you use the bind framwork.

Guice

Guice Guide

The Guice components do not have an own module, instead they are silently intertwined with the rest of the code. This means that

  1. Everything is usable without a Guice dependency,

  2. yet if you use Guice, integration with mela-command works as if it had first-class Guice support.

The usage of Guice in general is encouraged.

Use the Guice components if you use Guice anyway, especially if you use the bind framework.