Open Questions in Pattern Application

By Paul Preiss, of Iasa Global

How do you know when or when not to apply a pattern? How did you learn that? Which design artifact shows which pattern applies? What code (or data, ops component, security protocol, etc.) does it apply to?

I hear an infinite number of statements about how “our patterns” need to be awesome and “applying decisions” needs to be awesome, and how we need to be responsible for those. But I also find an almost infinite number of stories of it not working.

One of my goals is to bring rigor (scientific or semi-scientific excellence) to our architectural methods and techniques. The world is filled with marketing: Apply Patterns! Use Decision Records! Three easy steps. But the repeatability is absolutely miserable (as in, maybe in 1 out of 500 interviews or mentoring sessions is someone doing something repeatably).

So the cool factor for me is talking to enough people to create reusable techniques that others can succeed with. One of my greatest partners in this journey is a brilliant dude named Shawn McCarthy, who is a chief architect at Manulife and the chairman of the Chief Architect Forum. He is as passionate as I am about real data, real science and real outcomes.

So we decided, with four wonderful students and an amazing professor from UC Denver, to take on the science of pattern application in architecture.

As you may or may not know, we recently launched a 200-pattern library of common and experimental industry patterns in architecture. (That was a year of my life during which I realized just how bad the problem is in the field.) There was NO common reference point. The vendor repos, as they were, disagreed. There was NO science to this before. It is not nearly complete. But it is an excellent start (Patterns and Reference Models), and I really appreciate all the support we have gotten for this. And IF you want to dig into pattern ownership and leadership, I’M DYING for a pattern lead in the BTABoK.

As you also may or may not know, we have launched a BTABoK-based design tool at Iasa for understanding, testing and experimentation with architecture called Ergane.

ergane

Context View of Ergane in Ergane

So what are we actually building? I’m going to be careful here, because PAL isn’t running yet. What we have is a design, done properly, and I’d rather show you the design than sell you a demo.

What PAL does

PAL is a service that holds the BTABoK pattern library and does two jobs. First, it looks at a design card an architect is working on and recommends patterns that fit that design. Second, and this is the one I care about most, it checks the patterns you already chose to see if your design actually shows them the way the library describes them.

That second job is the one almost nobody does. We all say we “apply patterns.” Ask to see where the pattern is in the design and in the code, and the conversation gets very quiet.

We designed it using the method

Every part of PAL was designed on an Ergane board using BTABoK viewpoints. Seven cards, each answering a different question:

The Primary Context View. Where PAL sits among everything else in Ergane. It’s a domain service on the private network, called only by the board service. You saw this already.

An architecturally significant requirement. That means a requirement that changes the shape of the system if you get it wrong. Ours says PAL must recommend and check patterns from the current published library without slowing the board. That last bit drives half the design.

paul 3

A quality attribute card with six scenarios. A scenario is a specific situation with a measurable response.

An interaction model (usability viewpoint). Exactly what the architect sees and does, step by step.

A REST interface (integration viewpoint). The contract between the board service and PAL. Every call, every error, every timeout.

A latency budget (performance viewpoint). How long each step is allowed to take.

A deployment model. Where PAL runs and who can reach it.

Look at that list again. Someone asked me which design artifact shows which pattern applies. The honest answer is several of them, each from a different angle. And THAT is what this system is trying to solve!!!

For example, here:

paul 4

A Cache-Related Pattern?

Notice the caching? Well, hmm, how do we do that? Cache Aside? Where do we do it? Redis? Patterns and decisions … and how would you show that to a team to get answers or design it yourself? How do we visually do it? How do we do it in code?

When do you apply a pattern, and when not?

So back to those two things. It looks at the design you are working on and suggests patterns that might fit. And it checks the patterns you already chose to see if they are actually in the design the way the library says they should be.

That second one is the thing that gets me excited. In all those interviews and mentoring sessions, people could tell me which patterns they “used.” Almost nobody could show me where. The pattern lived in someone’s head … So the first real question we had to answer was simple. What does it even mean for a pattern to be applied? And can you see it?

The answer we landed on has four parts. There has to be a decision (someone chose this, here is why, here are the trade-offs). The pattern has to be recorded on the actual elements in the design it applies to. And there has to be a check that says whether the design really matches the pattern. Take any one of those away and you are back to opinions. The fourth is harder … applying it.

So in PAL, when you apply a pattern, it doesn’t change anything on its own. It drafts a decision record with the pattern, the elements it touches, the forces and the trade-offs pulled straight from the library. You edit it. You argue with it. You decide. Only when you accept it does the pattern get recorded on the design. Then PAL can check it and tell you it conforms, it is partial (and what is missing), or it is missing completely. And if it can’t check something, it says “not evaluated.” It never says you passed when nobody looked. That one rule alone would change half the architecture reviews I’ve sat in.

Then the drift work takes that same check down into the code. So you can follow a pattern all the way from the library, to a decision, to the design, to what got built. That is the chain I have wanted for about 20 years.

Where the science comes in

A pattern doesn’t live on one diagram. Take Cache Aside. You check the cache first, and if the item isn’t there, you go to the source, then you put the answer in the cache for next time. Simple enough on a whiteboard. But in a real design, that one pattern shows up in pieces across a whole set of views.

Look at our own PAL board. In the latency budget, there is a sequence where the board service looks in the answer cache, goes to PAL on a miss, then stores the answer. That’s the Cache Aside shape, right there in the messages. The quality attribute card has it as a tactic: an answer cache keyed by card version and library version. The context view has Redis sitting there. The deployment view says where the cache lives is still open. And the decisions list on the context view still says “Caching … undecided.”

So is Cache Aside applied? Kind of. It’s in the sequence, it’s in the tactics, it’s half in the deployment, and it has no decision behind it at all. That is a partial match, and you can only see that by looking at all the diagrams together.

THAT is the science question. How do you tell if a set of diagrams matches a pattern? Which parts of the pattern have to show up in which viewpoint? What counts as a match, what counts as partial, and what’s just missing? How do you tell a real Cache Aside from something that looks a bit like one? And when a pattern shows up in the sequence but not in the deployment, is the design wrong or the diagram?

Nobody has a real answer to this today. The vendor repos describe patterns as a picture and a paragraph. That’s fine for learning a pattern. It’s useless for checking one.

This is why every model in Ergane is structured. Each element has an ID, each relationship has a type, and each card knows its viewpoint. So PAL can compare a pattern against the actual elements and relationships across the cards, and come back with “conforms,” “partial” or “missing,” along with what it found. And every result points at specific elements, so you can go look and argue with it.

It also means the library has to grow up. Each of those 200 patterns needs to say what it looks like in a sequence, in a deployment view, in a context view, and which decisions and quality attributes it touches. So, back to that pattern lead. If you want to help turn 200 patterns into something the profession can actually prove works, call me.

[adbutler zone_id=”445800″]