Clean iOS Architecture pt.7: VIP (Clean Swift) – Design Pattern or Architecture?
Published: 2018-09-26 14:47:54

---
title: Clean iOS Architecture pt.7: VIP (Clean Swift) – Design Pattern or Architecture?
published: true
tags: 
canonical_url: https://www.essentialdeveloper.com/articles/clean-ios-architecture-part-7-vip-clean-swift-design-pattern-or-architecture
cover_image: http://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/58921b5a6b8f5bd75e20b0f4/5b97ab984fa51a9057c24d8f/1536667692697/thumbnail.png?format=1000w
---

{% youtube AnUcZUMGVBI %} [Watch on YouTube](https://www.youtube.com/watch?v=AnUcZUMGVBI?list=PLyjgjmI1UzlSWtjAMPOt03L7InkCRlGzb)

Today we're going to analyze the VIP (Clean Swift) Architecture. And, as we did in previous videos with [VIPER](https://dev.to/essentialdeveloper/clean-ios-architecture-pt6-viper--design-pattern-or-architecture-3f1f-temp-slug-2599990), [MVC, MVVM, and MVP](https://dev.to/essentialdeveloper/clean-ios-architecture-pt5-mvc-mvvm-and-mvp-ui-design-patterns-5ha5-temp-slug-7121127), we will decide if we can call VIP a Software Architecture or a Design Pattern.

The Clean Swift Architecture or, as also called, "VIP" was introduced to the world by [clean-swift.com](https://clean-swift.com) and, just like VIPER and other patterns, the main goals for the architecture were Testability and to fix the Massive View Controller problem.

The name VIP can be confused with VIPER, and interestingly enough the creators of VIPER [almost called it VIP](https://mutualmobile.com/resources/meet-viper-fast-agile-non-lethal-ios-architecture-framework) but decided to drop the name because it could stand for “Very Important Architecture,” which VIPER creators thought it was derogatory.

VIP is very similar to VIPER as both originated from [Uncle Bob's Clean Architecture](https://8thlight.com/blog/uncle-bob/2012/08/13/the-clean-architecture.html) ideas.

So can we consider VIP a Software Architecture or just a Design Pattern?

The VIP diagram describes its main structure, which explains its acronym definition: the ViewController/Interactor/Presenter relationship, or as they call it: The VIP cycle.

 ![The unidirectional VIP cycle.](https://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/t/5b97ac750ebbe8b81e090c9e/1536666750484/the-vip-cycle.png?format=1000w)

The unidirectional VIP cycle.

The VIP cycle differs from the VIPER relationship model described in our previous video. In VIPER, the communication between Interactor and Presenter, and View and Presenter is bidirectional.

 ![The bidirectional VIPER cycle.](https://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/t/5b97aca5cd8366c14a4dd945/1536666797140/viper.png?format=1000w)

The bidirectional VIPER cycle.

Instead, VIP follows a unidirectional approach, where the ViewController talks to the Interactor, the Interactor runs business logic with its collaborators and passes the output to the Presenter, and the Presenter formats the Interactor output and gives the response (or view model) to the ViewController, so it can render its Views.

Does this unidirectional communication model define an architecture? Also, are those 3 components (the ViewController, Interactor, and Presenter) enough to describe the Application Architecture?

It may seem like an architecture, but the VIP cycle is such a limited outlook of the application that we consider it a Design Pattern. And this design pattern has a name already: MVP. Regardless of what we call it, the MVP design pattern is not a software architecture.

However, VIP or "Clean Swift" has more components than just ViewControllers, Interactors, and Presenters, for example, Data Models, Routers and Workers.

Like VIPER, the Clean Swift author describes that VIP can have less or even more layers of separation, as needed. But the core must follow MVP or the VIP cycle! So the VIP cycle sounds more like an organizational design pattern that can solve the Massive View Controller problem and make your code more testable, but it doesn't describe the big picture or the “Software Architecture.”

VIP or Clean Swift, just like VIPER and other patterns, is trying to solve class dependency issues like the Massive View Controller and testability, rather than module dependency issues, like modularity. With the described Clean Swift components, we may end up with testable code but Spaghetti Architecture.

VIP also encourages the use of templates to "facilitate" its implementation. It can be very convenient to have templates, but, at the same time, it may create a limited framework to think. We don't believe there's a design pattern or "template" that can solve all the problems and can be infinitely extended. We believe that, instead of trying to fit every problem into a template, every software architecture must be carefully crafted to solve the system challenges. For example, some systems would benefit more from an Event-Driven (Producer/Consumer) streaming model where other systems would not.

Let's have a look at the [Clean Swift sample project (CleanStore)](https://github.com/Clean-Swift/CleanStore) dependencies diagram.

 ![CleanStore sample project class and module dependencies diagram.](https://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/t/5b97ad101ae6cfbcdbd675a7/1536666904060/diagram-1.png?format=1000w)

[CleanStore sample project](https://github.com/Clean-Swift/CleanStore) class and module dependencies diagram.

As you can see, there are arrows everywhere, crossing module boundaries, so changes to the software can break multiple modules (and of course, numerous tests...).

In the Clean Swift sample app, the application is separated in scenes (or modules). There’s a List Orders Scene, Create Order Scene and Show Order Scene. A higher level look at the modules dependencies shows that scenes are highly coupled with each other and with other system’s components.

 ![High-level modules dependencies diagram shows a highly coupled architecture.](https://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/t/5b97ad3a40ec9af58bd2391d/1536666949774/diagram-2.png?format=1000w)

High-level modules dependencies diagram shows a highly coupled architecture.

Another way to look at the application architecture is to examine its modules in a circular form so we can see the dependencies between the modules. The closer to the center, the more abstract and independent the module is.

 ![High-level modules dependencies diagram shows a highly coupled, monolithic architecture.](https://static1.squarespace.com/static/5891c5b8d1758ec68ef5dbc2/t/5b97ad6e575d1f202ba3b2b9/1536667007880/diagram-3.png?format=1000w)

High-level modules dependencies diagram shows a highly coupled, monolithic architecture.

Different than Uncle Bob’s Clean Architecture, we can see services, frameworks, and drivers in the core rings. Also, inside each scene, some Interactors might contain business logic, and they depend on frameworks and other services. Throughout the codebase, we can even notice that core models are used in all levels of abstraction (UI/Presentation/Business Logic/Routing/Services/Workers) which is a no-no in Uncle Bob’s Clean Architecture.

The VIP sample app architecture is a highly coupled and monolithic architecture. If we want to create a somewhat testable monolith, it might work well. However, we might quickly find out that the lack of modularity prevents us from scaling the team, moving fast and prevents us from achieving key business metrics. For example:

- Deployment Frequency
- Estimation Accuracy
- Lead Time for Changes
- Mean Time to Recover

As explained in the previous video, we believe that software architecture is less about types, classes, and even responsibilities and more about how the components communicate to each other, how they depend on each other, and what is the shared understanding of the senior developers regarding: What are the important parts? What is coupled? What is decoupled? What is hard to change, What is easy to change? How is the data flowing between layers and why – is the data going in one direction? Two directions? Multiple directions? Can we support the business short and long-term goals?

We would like to reinforce that our codebases are like living organisms and they're changing all the time. So does the architecture. It's continually evolving, and there are no templates for that.

At Essential Developer, we do believe software architecture has a strong correlation with Product Success, Product Longevity, and Product Sustainability. We advise professional developers to learn from Uncle Bob's Clean Architecture, VIP, VIPER, MVC, MVVM, MVP, and other patterns, but not try to copy and paste solutions. Remember: Every challenge is different, and there are no silver bullets.

VIP, VIPER, MVC, MVVM, MVP, as design patterns, can guide you towards more structured components. However, they don't define the big picture or the Software Architecture. So, use them with care!

For more, visit [the Clean iOS Architecture Playlist](https://www.youtube.com/watch?v=PnqJiJVc0P8&list=PLyjgjmI1UzlSWtjAMPOt03L7InkCRlGzb).

[Subscribe now to our Youtube channel](https://www.youtube.com/essentialdeveloper?sub_confirmation=1) and catch **free new episodes every week**.

* * *

Originally published at [www.essentialdeveloper.com](https://www.essentialdeveloper.com/articles/the-importance-of-discipline-for-ios-programmers).

We’ve been helping dedicated developers to get from low paying jobs to **high tier roles – sometimes in a matter of weeks!** To do so, we continuously run and share free market researches on how to improve your skills with **Empathy, Integrity, and Economics** in mind. If you want to step up in your career, [access now our latest research for free](https://www.essentialdeveloper.com/courses/career-and-market-strategy-for-professional-ios-developers).

## Let’s connect
If you enjoyed this article, visit us at [https://essentialdeveloper.com](https://essentialdeveloper.com) and get more in-depth tailored content like this.

Follow us on: [YouTube](https://youtube.com/essentialdeveloper) • [Twitter](https://twitter.com/essentialdevcom) • [Facebook](https://facebook.com/essentialdeveloper) • [GitHub](https://github.com/essentialdevelopercom)