SCF in 5 minutes

The aim of the framework

Splitting complex requirements into little pieces of software is a good approach in software development. Think of micro services: Small pieces of software fulfill a part of functionality. If you put them together you've a powerful application.The smallest unit in the SCF is the Command object. A Command is a java class which provides a little piece of functionality in it's executeCommand() - method. The glue between several Command objects is the ParameterObject. This can be anything derived from java.lang.Object which is not final (of course you want to change values).

Add the framework into your maven project

To run unit tests add the following dependency in maven for supporting JUnit 5:

Browse the JavaDoc for more information

Start implementing your first test

  • Line 18: The first test is a test of the factory method. It is best practice to provide a factory method for each command.
  • Line 29: Here is the actual implementation of the executeCommand() method. For a simple use of commands this is the entry point of your business logic.
  • Line 30: The framework works with parameter objects. SCF offers a generic implementation of such an object. It is best practice to create your own object but if you want to reuse the command in several environments it make sense just work with the generic one.

We want to assert that a key is generated in the command with value "Hello World" and the command executes with result SUCCESS.

Start implementing your first command

To prevent to implement the legacy methods all the time, you can implement an AbstractDefaultCommand.

Create a second command

Sticking both commands together


SCF is a framework is need for all situations where you

  • want to write code fragments, which are loose coupled.
  • want to write command chains which you will execute.
  • want to write strategies.

SCF comes with interfaces and default implementation.

This example is part of simple-command-tools. You can clone it or download it directly here.

Learn more about the Simple Command Framework.