Requirements to Code (R2C)

Recall that in the Model-View-Controller architecture views send commands to controllers. For example, when the user selects an item on a menu, a command such as "print" or "save" is sent to a controller. It is the job of the controller to interact with the model in order to execute the command.

The Use Case Controller design pattern maps use cases to controllers. In this project we explore the possibility of formalizing this mapping as a Java-based code generator called R2C.

R2C is essentially a code generator. The user specifies a requirements model and a target directory. R2C populates the target directory with .java files containing the application's model, views, and controllers. The user then customizes these files by adding the appropriate details.

The Requirements Model

Internally (i.e., inside R2C) the requirements model is an object containing a bunch of use case objects:

R2C will associate to each use case an extension of the abstract UseCaseController class. This class implements the control logic for updating the model.

Externally, the requirements model is all or part of an XML file. For example, StarUML saves projects in an XML file with a .uml extension.

In the final version of R2C the external file will need to be parsed into a DOM tree. The internal model is constructed from this tree.

The Framework

The framework instantiates the Model-View-Controller architecture. The central class is a JFrame called Application:

The Application is a desktop window that contains 0 or more Views of the Model. The Model and View classes are abstract.

Use case controllers are (or contain) listeners for menu items:

The Application

Assume a developer creates the following requirements model for an ATM:

 

R2C generates the following classes (shown in yellow):

In addition, R2C generates a class called Main:

class Main {
   public static void main(String[] args) {
      framework.Application app = new framework.Application();
      app.setModel("ATMModel");
      app.createView("ATMView");
      app.setVisible(true);
   }
}

(When to the controllers get created and where are they? What about the menubar?)