Design and Architecture
Since we reached the conclusion that a web services solution would be less than optimal (refer
to the previous chapter), a decision to implement a pure web based solution was made. We
decided to use the current transaction model specification application described in [5] as our
starting point, taking advantage of already existing good ideas. At the same time our main
focus was addressing as many of the shortcomings of the current solution as possible. We
decided to base our implementation on two main concepts, the tree control and the Model-
View-Controller pattern. These concepts are discussed in the following sections.
5.1 Tree Control
Since the transaction model specifications leads to a tree structure of transactions,
subtransactions and operations, we felt that the user interface should have a strong focus on
this tree structure. In the original solution, only a textual representation of the tree structure is
possible, and only when specifying transactions and operations. Additionally it is not possible
to see the tree structure of more than one root transaction at a time. We decided to base much
of our interface on a graphical representation of the tree structure. Additionally we wanted the
user to be able to interact with the tree structure, e.g. selecting transactions and operations by
clicking on them in the tree. This is the kind of functionality one finds in for example
Windows Explorer, the Windows operating system’s file management utility. Figure 5.1
shows an example of the tree control in Windows Explorer. We decided to use a similar tree
control for representing transactions and operations in our application.
22
Chapter 5 Design and architecture
5.2 MVC Pattern
Since the current solution suffers from poor design, we decided to pay close attention to this
aspect of our solution. This meant trying to incorporate some best practices of software
design. More specifically we wanted to base our solution, at least to a certain degree, on the
Model-View-Controller (MVC) design pattern.
The Model-View-Controller pattern was created by Xerox PARC for Smalltalk-80 in the
1980s. The pattern was invented for decoupling the graphical interface of an application from
the code that actually does the work [11]. It has since then become a widely used software
design pattern, becoming particularly popular in web application development. MVC is the
recommended model for Sun’s J2EE platform
7.
As the name implies an application is divided into three components, also called participants
[12], [13]:
• Model – The model represents enterprise data and business rules that govern access to
and updates of this data. This is where most of the processing takes place when using
MVC. Databases and component objects like Enterprise JavaBeans
8fall under the
model. The model does not apply any formatting to data, meaning that the data
returned from the model is display-neutral.
• View – The view is the user interface the user sees and interacts with. Technically
speaking, the view renders the content of a model by accessing enterprise data through
the model and specifying how that data should be presented. No processing takes
place in the view, however it is the view’s responsibility to update its presentation
when the model changes.
• Controller – The controller translates interactions with the view into actions to be
performed by the model. Based on user interactions and the outcome of the model’s
actions, the controller determines what formatting to apply to the resulting data by
selecting an appropriate view.
A graphical presentation of the MVC pattern is shown in figure 5.2 [12].
7
See http://java.sun.com/blueprints/patterns/MVC.html
8See http://java.sun.com/products/ejb/
5.2 MVC Pattern
23
Figure 5.2: The MVC design pattern
There are several reasons to use the MVC pattern. First of all it enables multiple views that
rely on the same model. This means that different types of clients can access the same data,
e.g. you can have a HTML interface and a WAP interface that both rely on the same
underlying data. This saves you the effort of writing and maintaining separate data models for
each view. It also makes it a lot easier to add a new type of client, all that needs to be done is
create the view and modify the controller.
The second advantage of using the MVC pattern is that the model can changed without the
need to change the rest of the application. An example of this is changing the underlying
database from one vendor to another. If written correctly, the view does not care where its
data comes from.
The drawback of the MVC controller is that it introduces quite a lot of complexity into an
application. It also makes the planning effort necessary to develop an application larger, since
you have to pay extra attention to the details of how different parts of the application will
interact. This means that a full blown MVC implementation may be overkill for small
applications, but extremely useful for large, enterprise applications.
25
In document
An improved web-based solution for specifying transaction models for CAGISTrans
(Page 31-35)