Five-Step UML: OOAD for Short Attention Spans - Design, Repeat - Adding Swimlanes (
Page 8 of 13 )
Adding swimlanes to our Component Activity Diagram for the Get or Add Owner use case (Figure 2-37), we get the Activity Diagram shown in Figure 2-44, where the Owner Info interface is realized in a gateway class, COwnerInfo, which carries out the assigned method.

Figure 2-44. Activity Diagram for the Get or Add Owner use case, with swimlanes
Usually, a gateway class relies upon deeper classes and interfaces to carry out its responsibilities; here, that’s COwnerSet, which does the work of calling into the SQL database.
Although we could have had COwnerInfo call directly into a SQL database to work with owners, that’s not the wisest implementation. I like to isolate the SQL handling inside wrapper classes, because SQL itself isn’t inherently object-oriented. Mixing SQL’s relational behavior into the design may make matters more confusing.
Furthermore, I usually have a wrapper class that represents a table or result set, and another class that represents one record in the set. The set class supports lookup, creation, and deletion. The record class supports editing and (perhaps) deleting. Both classes make use of a SQL interface to the database.
Note how the SQL interface wasn’t previously reflected in our architecture. Depending on our organization rules, this might be a decision that a component team can make on its own, because other teams don’t need to know how the team implements its responsibilities; or it might require the architecture team to add the interface, select a SQL engine, and update the architecture, as shown in Figure 2-45.

Figure 2-45. Component Diagram for the Kennel Management System, ninth revision
Again, the real design process is sloppy and iterative, with a lot of feedback and retracing of steps. Just as architecture influenced requirements, design will influence architecture.
SQL Code or Stored Procedures?
Notice the two activities assigned to the SQL interface: Select Owner and Insert Owner. These might correspond to actual SQL Select and Insert and Update statements; or you might make SQL stored procedures to carry out those tasks.
A stored procedure is a canned set of SQL statements—Select, Insert, Update,
and a number of other commands—that may be called with parameters and
that look from outside the database as a single SQL call. (Depending on your
database engine, a stored procedure may also be compiled and optimized for
better performance.)
I prefer to consider these activities as stored procedures (it lets me think of SQL
more like an interface to a service than like a complex language), but this diagram
doesn’t actually reflect that. So to make my SQL intentions clearer, I like to use
two new custom stereotypes for transitions: «SQL» for hard-coded SQL calls,
and «stored proc» for SQL stored procedure calls. So the diagram in Figure 2-44
can be revised as shown in Figure 2-46.

Figure 2-46. Activity Diagram for the Get or Add Owner use case, with swimlane, second revision
.............................................................................................