Last time I explained about Parts using a small example.  But the idea of Parts can extend equally well, if not better, to large examples.  Let’s say we have an ordering system that contains a couple of databases, and an ordering module, and an administration module.  Using Parts this can be depicted thus:

image

This shows that the Admin part is connected to the Customers and Orders databases, and the Ordering part is also connected to the Customers and Orders databases.   The classes Admin, Ordering and Database need to be defined somewhere.  They could be defined as nested classes of OrderingSystem, or elsewhere.  Let’s put them elsewhere, into a couple of Packages.

image

In a case like this we’d like to say more, in particular which aspects of the databases each module connects to. This is where Ports come in.  Let’s add some Ports to the Database parts.

image

Now to do that, in fact we have to add the Ports to the Database class itself.  The apparent Ports on the Parts are not really Ports; they are actually usages within the context of the OrderingSystem of Ports defined on the Database class.

image

The Database class defines two Ports: a, which provides the IAdmin interface, and q, which provides the IQuery interface.  You’ll see in a moment why I have used such short names.  Ports have types, and provide and require Interfaces as a consequence.  The simplest kind of port is one whose type is a single interface, in which case the port provides that interface, as for both of the ports here.  Now we can put this additional information into the definition of OrderingSystem, to show which Ports are hooked up to which Connectors.

image

It gets quite busy visually with all of those labels (and there are other adornments I could have put on the connector ends if I’d wanted, such as multiplicities).  Still, the model now shows how the Ordering and Admin parts hook up to the databases via Ports. The Connectors represent communication links, and the Ports show which interfaces the communications can use.

Next time we’ll look at Components and how they extend these capabilities.