4 + 1 View Model of Architecture

4 + 1 View Model of Architecture

The concept of 4+1 view was introduced by Philippe Kruchten in his paper: The 4+1 View Model of Architecture.

To make it simple, it’s a way of creating multiple point of views for the development of a software. There are 4 “simple” views and one that glue them all together. The first four one are :

  • The pogical view
  • The process view
  • The realisation view
  • The physical view

The one that glues them all together is the use cases view. All the other views will tend to answer the questions asked by this view, in order to satisfy the user’s requirements.

In the world of mobile development, the physical view (the one about the bandwidth, the geographical constraints, etc.) is generally not that important because it will be handled by the stores on which you will push your app (of course if it’s your own store then it could become a question). So let’s focus on the 3 other ones quickly:

  • The logical view is all about classes, interfaces and objects
  • The process view is all abouth threads and the way objects interact
  • The realisation view is all about domain, libraries and meta-components

Start with the realisation view

On which one should you focus? Well it all depends when you are in your process. If you are at the beginning of the development, you should focus on the realisation view. In here you will start fixing the global decoupling and which external libraries you want to use and if you should be protected against them or not. Of course, this will have some impacts on the logical View. You should look at your realisation View from time to time to be sure that your libraries are still working as desired, if some updates are required and/or some fixing should be done (security features, improvements, etc.). I would say that a good practice is to look at it every 2 sprints (in our case, at mototomo.io, we do it once a month).

Now that you have started your sprints, then goes the time for the 2 other views. The process view is all about threads. It’s an easy one when you are on a mono thread logic (Javascript guys, this view is useless for you…), but it can be a tricky one when you are on a multithreaded device. We are working (suffering) on it at the moment at mototomo.io (to detect if multi-threading is damaging your app).

The logical view is where your fine grained architecture is

But let’s take a final look at the logical view. It’s the view where your architecture is visible. The major problem is that you will have to draw/redraw it all the time. For some senior developers, it is as if it was inconsciously present all the time (they see this hidden structure hidden behind the code), but for more junior developers they generally tend to forget about it and try the easy way. Well that’s working on a short run, but on the long run, it will make the project fail. How can you draw this all the time, well one solution is by hand. This is nice, you will spend loads of time but at the end you will know the app for sure (I’m not sure your manager will appreciate it but that’s a negociation).

The other solution is to get an automatic tool that will do it for you

Resource:

  • Philippe Kruchten, “The 4+1 View Model of Architecture” (IEEE Software, 1995)
  • Nathalie Gaertner/Pierre-Alain Mueller, Mod√©lisation Object avec UML (Eyrolles, 2000)