Professional Documents
Culture Documents
An architectural mechanism used during the design process, during the period in
which the details of the design are being worked-out (elaborado). They are related
to associated analysis mechanisms, of which they are additional refinements, and
they may bind (vincular) one or more architectural and design patterns (patrones).
There is not necessarily any difference in scale between the analysis mechanism
and the design mechanism? It is thus possible to speak of a persistence
mechanism at the analysis level and the design level and mean the same thing, but
at a different level of refinement. ; A design mechanism assumes some details of
the implementation environment, but it is not tied to a specific implementation (as is
an implementation mechanism). For example, the analysis mechanism for inter-
process communication may be refined by several design mechanisms for inters
process communication (IPC): shared memory, function-call-like IPC, semaphore-
based IPC, and so on. Each design mechanism has certain strengths and
weaknesses; the choice of a particular design mechanism is determined by the
characteristics of the objects using the mechanism.
Architectural pattern
Analysis mechanism
An architectural mechanism used early in the design process, during the period of
discovery when key classes and subsystems are being identified. Typically
analysis mechanisms capture the key aspects of a solution in a way that is
implementation independent. Analysis mechanisms are usually unrelated
(desligado) to the problem domain, but instead are "computer science" concepts.
They provide specific behaviors to a domain-related class or component, or
correspond to the implementation of cooperation between classes and/or
components. They may be implemented as a framework. Examples include
mechanisms to handle persistence, inter-process communication, error or fault
handling, notification, and messaging, to name a few.
Implementation mechanism
Framework
Now we must begin the refine the information gathered on the analysis
mechanisms. The steps for doing this are as follows:
Identify the clients of each analysis mechanism. Scan all clients of a given
analysis mechanism, looking at the characteristics they require for that mechanism.
For example, a number of Analysis Classes may make use of a Persistence
mechanism, but their requirements on this may widely vary: a class which will have
a thousand persistent instances has significantly different persistence requirements
than a class which will have four million persistent instances. Similarly, a class
whose instances must provide sub-millisecond response to instance data will
require a different persistence approach than a class whose instance data is only
accessed through ad-hoc queries and batch reporting applications.
Conduct a search for the right components, or build the components. You will
often find that there is no apparently suitable implementation mechanism for some
design mechanisms; this will trigger a search for the right product, or identify the
need for in-house development.
You may also find that some implementation mechanisms are not used at all.
The choice of implementation mechanisms is based not only on a good match for
the technical characteristics, but also on the non-technical characteristics, such as
cost. Some of the choices may be provisional; almost all have some risks
attached to them: performance, robustness, and scalability are nearly always
concerns and must be validated by evaluation, exploratory prototyping, or inclusion
in the architectural prototype.
The role of the Software Architect in this activity is to decide upon and validate
these mechanisms by building, or integrating them, and verifying that they do the
job, and then consistently imposes them upon the rest of the system design. The
software architect role collaborates with the process engineer role to document the
mechanisms and details regarding their use in project-specific design guidelines.
See Activity: Prepare Project Specific Guidelines. The relationship (or mapping) of
analysis mechanisms to design mechanisms to implementation mechanisms, and
the associated rationale for these choices, should be documented in the Software
Architecture Document. The mechanisms themselves are Design Model elements
(such as Design Package, Design Class, and Design Subsystem) which are
detailed in Artifact: Design Model as part of their respective design activities.
There might be a need for many (2,000) small objects (200 bytes each) to be
stored for a few seconds, with no need for survival.
There might be a need for several very large objects to be stored permanently
on disk for several months, never updated, but with sophisticated means of
retrieval.
These objects will require different support for persistency; the following
characteristics of design mechanisms for persistency support might be identified:
Note that these speeds are only rated 'slow' relative to in-memory
storage. Obviously, in some environments, the use of caching can improve
apparent access times.
Too many different design mechanisms make the system too complex.
Too few design mechanisms can create performance issues for some
implementation mechanisms that stretch the limits of the reasonable ranges of
their characteristics values.
Once you decide to use a DBMS to store objects of class A, you might be tempted
to use it to store all objects in the system. This could prove very inefficient, or very
cumbersome. Not all objects which require persistency need to be stored in the
DBMS. Some objects may be persistent but may be frequently accessed by the
application and only infrequently accessed by other applications. A hybrid strategy
in which the object is read from the DBMS into memory and periodically
synchronized may be the best approach.
Example
A flight can be stored in memory for fast access, and in a DBMS for long
term persistency; this however triggers a need for a mechanism to
synchronize both.
It is not uncommon to have more than one design mechanisms associated with a
client class as a compromise between different characteristics.
Example
An exact 'fit' with the requirements of the clients of the design mechanism, in
terms of the expected characteristics.
The cost and complexity of having too many different implementation
mechanisms to acquire and integrate.
The overall goal is always to have a simple clean set of mechanisms that give
conceptual integrity, simplicity and elegance to a large system.
Once you have finished optimizing the mechanisms, the following mappings exist:
The design decisions for a client class in terms of mappings between mechanisms;
the Flight class needs two forms of persistency: in-memory storage implemented
by a ready-made library routine, and in a database implemented with an off-the-
shelf ObjectStorage product.
The map must be navigable in both directions, so that it is easy to determine client
classes when changing implementation mechanisms.
Design mechanisms, and details regarding their use, are documented in the
Artifact: Project Specific Guidelines. The relationship (or mapping) of analysis
mechanisms to design mechanisms to implementation mechanisms, and the
associated rationale for these choices, is documented in the Artifact: Software
Architecture Document.
As with analysis mechanisms, design mechanisms can be modeled using a
collaboration, which may instantiate one or more architectural or design patterns.
The figure Static View: JDBC shows the classes (strictly, the classifier roles) in the
collaboration.
The yellow-filled classes are the ones which were supplied; the others (myDBClass
etc.) were bound by the designer to create the mechanism.
In JDBC, a client will work with a DBClass to read and write persistent data. The
DBClass is responsible for accessing the JDBC database using the
DriverManager class. Once a database Connection is opened, the DBClass can
then create SQL statements that will be sent to the underlying RDBMS and
executed using the Statement class. The Statement class is what “talks” to the
database. The result of the SQL query is returned in a ResultSet object.
The DBClass class is responsible for making another class instance persistent. It
understands the OO-to-RDBMS mapping and has the behavior to interface with the
RDBMS. The DBClass flattens the object, writes it to the RDBMS and reads the
object data from the RDBMS and builds the object. Every class that is persistent
will have a corresponding DBClass.
We now present a series of dynamic views, to show how the mechanism actually
works.
JDBC: Initialize
To initialize the connection to the database, the DBClass must load the appropriate
driver by calling the DriverManager getConnection() operation with a URL, user,
and password.
Parameters:
user: The database user on whose behalf the Connection is being made
Returns:
To create a new class, the persistency client asks the DBClass to create the new
class. The DBClass creates a new instance of PersistentClass with default values.
The DBClass then creates a new Statement using the Connection class
createStatement() operation. The Statement is executed and the data is inserted
into the database.
JDBC: Read
To read a persistent class, the persistency client asks the DBClass to read. The
DBClass creates a new Statement using the Connection class createStatement()
operation. The Statement is executed and the data is returned in a ResultSet
object. The DBClass then creates a new instance of the PersistentClass and
populates it with the retrieved data. The data is returned in a collection object, an
instance of the PersistentClassList class.
Note: The string passed to executeQuery() is not necessarily exactly the same
string as the one passed into the read(). The DBClass will build the SQL query to
retrieve the persistent data from the database, using the criteria passed into the
read(). This is because we do not want the client of the DBClass to need the
knowledge of the internals of the database to create a valid query. This knowledge
is encapsulated within DBClass.
JDBC: Update
To update a class, the persistency client asks the DBClass to update. The
DBClass retrieves the data from the given PersistentClass object, and creates a
new Statement using the Connection class createStatement() operation. Once the
Statement is built the update is executed and the database is updated with the new
data from the class.
Remember: It is the job of the DBClass to "flatten" the PersistentClass and write it
to the database. That is why is must be retrieved from the given PersistentClass
before creating the SQL Statement.
Note: In the above mechanism, the PersistentClass must provide access routines
for all persistent data so that DBClass can access them. This provides external
access to certain persistent attributes that would have otherwise have been private.
This is a price you have to pay to pull the persistence knowledge out of the class
that encapsulates the data.
JDBC: Delete
To delete a class, the persistency client asks the DBClass to delete the
PersistentClass. The DBClass creates a new Statement using the Connection
class createStatement() operation. The Statement is executed and the data is
removed from the database.
In the implementation of this design, some decisions would be made about the
mapping of DBClass to the persistent classes, e.g. having one DBClass per
persistent class and allocating them to appropriate packages. These packages will
have a dependency on the supplied java.sql (see JDBC™ API Documentation)
package which contains the supporting classes DriverManager, Connection,
Statement and ResultSet.