11.9.  Introducing Connection Schemes

If you look closely you will find that both connection blocks in "Customer" and "Product" are absolutely identical. Now image you had to connect dozens of artifacts in this way. That would be quite annoying and error prone. To avoid this kind of duplication we added the concept of connections schemes:

// File modules.arc
connection-scheme C2C
{
    connect UI to target.UI, target.Controller, target.Model
    connect Controller to target.Controller, target.Model
    connect Model to target.Model
}

artifact Customer
{
    include "Customer/**" // All in module "Customer"
    apply "layering"
    
    connect to Core using C2C // connection scheme C2C
}
artifact Product
{
    include "Product/**" // All in module "Product"
    apply "layering"
    
    connect to Core using C2C
}
artifact Core
{
    include "Core/**" // All in module "Core"
    apply "layering"
}
    

Now I hope you agree that this is cool. Using connection schemes it becomes possible to describe the wiring between artifacts in an abstract way. That makes it easy to change the wiring if the architect comes up with a new idea or wants to add or remove restrictions.

In big systems you may need some additional nesting to avoid having too many toplevel artifacts:

artifact SystemPartA
{
    //...
    artifact A
    {
        //...
        apply "layering"
    }
    
    artifact B
    {
        //...
        apply "layering"
    }
    
    connect to SystemPartB using Part2Part
}

arifact SystemPartB
{
    //...
    artifact C
    {
        //...
        apply "layering"
    }
    
    artifact D
    {
        //...
        apply "layering"
    }
}

connection-scheme Part2Part
{
    // Please note the use of "any"
    connect any.UI to target.any.UI, target.any.Controller, target.any.Model
    connect any.Controller to target.any.Controller, target.any.Model
    connect any.Model to target.any.Model
}
    

Here parts contain nested parts which share a common layering. The use of the keyword any allows to insert a wildcard for those nested parts into the scheme. In our example each wildcard connection defined in the scheme would result in 4 real connections since each part has 2 nested parts here (A.x to C.x, A.x to D.x, B.x to C.x and B.x to D.x). To keep the number of connections under control only one any is allowed on each side of a wildcard connection.