added description of ui architecture pattern used

This commit is contained in:
Manfred Karrer 2014-08-28 19:34:47 +02:00
parent fb89f087f0
commit d30a41b54b
5 changed files with 96 additions and 65 deletions

View file

@ -42,31 +42,6 @@ import javafx.scene.layout.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* Code behind (We don't call it controller as controller is associated with the classical MVC controller):
* <p>
* - Knows the presentation model, does not know the model
* - Has no logic and no state
* <p>
* - Creates presentation model and passes model from Guice injection to the presenter. Does not hold any reference to the model.
* //TODO is there a better way for DI of model?
* - Setup binding from presenter to view elements (also bidirectional - used for input data). Binding are only to plain
* presenter properties. There are no logical bindings or cross-view element bindings.
* - Listens to UI events (Actions) from view and calls method in presentation model.
* - Is entry node for view graph and responsible for navigation and creation of new views.
* - Passes application API method calls to Presenter. Calls application methods on sub views.
* - Handle lifecycle and self removal from scene graph.
* - Can contain non-declarative (dynamic) view definitions (if it gets larger, then use a dedicated ViewBuilder)
* <p>
* View:
* - Typically declared in FXML. Dynamic parts are declared in Controller. If more view elements need to be defined in
* code then use a ViewBuilder.
* <p>
* ViewBuilder (optional):
* - Additionally or instead of FXML view. If no FXML then controller setup need to be handles by ViewBuilder.
* <p>
* Note: Don't assign the root node as it is defined in the base class!
*/
public class CreateOfferCB extends CachedViewController {
private static final Logger log = LoggerFactory.getLogger(CreateOfferCB.class);
@ -88,6 +63,7 @@ public class CreateOfferCB extends CachedViewController {
// Constructor
///////////////////////////////////////////////////////////////////////////////////////////
//TODO find a better solution, handle at base class?
@Inject
public CreateOfferCB(CreateOfferModel model) {
pm = new CreateOfferPM(model);

View file

@ -52,12 +52,9 @@ import org.slf4j.LoggerFactory;
import static com.google.common.base.Preconditions.checkArgument;
/**
* Data model:
* Does not know the Presenter and View (CodeBehind)
* Use Guice for DI to get domain objects
* <p>
* - Holds domain data
* - Apply business logic (no view related, that is done in presenter)
* Domain for that UI element.
* Note that the create offer domain has a deeper scope in the application domain (TradeManager).
* That model is just responsible for the domain specific parts displayed needed in that UI element.
*/
class CreateOfferModel {
private static final Logger log = LoggerFactory.getLogger(CreateOfferModel.class);

View file

@ -42,17 +42,6 @@ import org.slf4j.LoggerFactory;
import static io.bitsquare.gui.util.BSFormatter.*;
import static javafx.beans.binding.Bindings.createStringBinding;
/**
* Presentation model:
* Knows Model, does not know the View (CodeBehind)
* <p>
* - Holds data and state of the View (formatting,...)
* - Receive user input via method calls from CodeBehind.
* - Validates input, applies business logic and converts input to Model.
* - Format model data to properties used for binding from the view (The view setup the bindings).
* - Listen to updates from Model via Bindings (The PM setup the bindings to the model).
* - Can be used for unit testing
*/
class CreateOfferPM {
private static final Logger log = LoggerFactory.getLogger(CreateOfferPM.class);