Skip to content
This repository has been archived by the owner on May 3, 2019. It is now read-only.

Architecture

Colin Duquesnoy edited this page Jun 24, 2017 · 9 revisions

Onion Architecture

This architecture is an overly simplified version of the the clean architecture described by Uncle Bob.

The content of this page is very theorical and may change in the future to reflect the reality of the code.

The main objective of this architecture is separation of concerns. The most important rule to know about this architecture is that source code dependencies can only point inwards.

MellowPlayer developers should strive to respect the SOLID Principles.

Application

This layer contains some business objects directly usable by the Infrastructure and Presentation layers and defines a series of interfaces that are either implemented in the Infrastructure or the Presentation layers. The idea is that details should depend upon abstractions and not the inverse.

No file system calls, no network oparations and NO MULTITHREAD in this layer. All classes should be unit tested (using mocks to avoid any system call in the unit tests).

Presentation

This layer mainly contains the UI elements of the application. We use a mix of MVVM pattern and Qt Model/View patterns. ModelView is simply named Views. ViewModels expose different propertiers to the view and allow the view to call into business logic. There are a series of Models which are based on QAbstractItemModel to feed the various list views of the application.

Views should be tested using QtTests module for QML (this is not the case at the moment). ViewModels and Models can be unit tested as they know nothing about views and do not need a qml runtime to work.

Infrastructure

This layer contains code related to the infrastructure. Code that need to access the file system, a db or the network should be located here. Multi-threaded operations should be performed here, we don't want to have any mutex/locks in the inner layers.

This layer is mainly tested using integration tests.

Code structure

Top level directories

  • 3rdparty: this directory contains 3rd party libraries
  • docs: this directory contains the documentation (user manual and plugin developer documentation)
  • lib: this directory contains the various static libraries use by the application. There is one static library per layer (Entities, UseCases, Presentation, QmlFrontend and Infrastructure).
  • scripts: this directory contains the various helper scripts (CI setup, packaging,...)
  • src: this directory contains the main executable of the application. It should contains as few code as possible.
  • tests: this directory contains unit tests and integration tests. It is organised the same way as the lib directory.

Lib/Tests directories

The lib and tests directories are organised in the same way, there is one subdirectory per static library.

  • Infrastructure
  • Presentation
  • Application

There is a different test executable but for each kind of tests (Unit tests, Integration tests).