Table of Contents

Skip to end of metadata
Go to start of metadata
Inhalt

Verweise

 

STATUS

In this section there are some best practices to work with the Simple Command Framework.

 

This section is still in progress

 

Use your own ParameterObject / Context

It is just a question of usage:

  • If you have a library of commands which you want to stick together in various project it is better to deal with generic parameter objects. In this case you can use the default implementation DefaultParameterObject. The disadvantage of this approach is that you've to deal with strings. Recommendation: Use string constants to work with keys. Every command should have constants for the possible keys inside.
  • If you deal with parameter objects in a own chain you should provide a parameter object with get- and set-methods because it is safe. You can use any object for parameter objects still objects which are generated from other frameworks.

 

 

Use the factory pattern to create new Command objects.

It is good practice to create domain objects via the factory pattern. You may provide an getInstance() method in every command or a factory object which offers methods for creation of all commands. Factory pattern gives you the opportunity to change the behavior of object creation. Because SCF works with parameter objects it is also thread safe to work with singletons across multiple threads.

 

Place the whole business logic in the executeCommand() method

 

Deal with default implementations

 

Configure Chains via XML / Spring

 

  • No labels