Although Alistair Cockburn published Hexagonal Architecture (a.k.a. the Ports-and-Adapters pattern) in 2005, I haven't seen it used in any Qt embedded application. That's a pity, because it should be the standard architecture. Architects and developers should not have to justify why they use it, but why they don't use it.
The idea of the Ports-and-Adapters pattern can be illustrated with USB ports. If we want to connect devices over RS232, UART, CAN, Ethernet or HDMI with a computer these days, we need a USB adapter. As long as the adapter conforms to the USB standard, the communication between computer and device will work.
Hexagonal Architecture transfers the USB ports-and-adapters idea from hardware to software. The business logic (the inside world) is the core of the application. It provides several ports or interfaces for components from the outside world. As long as we adapt the components to the ports, the application will work. The ports prevent the inside world from leaking to the outside world and vice versa.
The HMI, CLI and test adapters use the same Model port. If they can do so without code changes, the business logic is contained behind the port. The CAN, Ethernet and mock adapters implement the Machine port used for the communication between the Qt application and the machine. When we use the test adapter for the Model port and the mock adapter for the Machine port, we can test the business logic.
The Machine port allows us to replace CAN by Ethernet communication, when the CAN bandwidth isn't sufficient any more in five years. We can also provide one adapter that communicates with the real machine and another adapter that communicates with a machine simulator.
Hexagonal Architecture comes with many advantages. It makes it easy to replace one technology for, say, the machine or cloud communication by another: just add an adapter. So, we can easily extend our applications over their lifetime. Hexagonal Architecture has testing built in with the test and mock adapters from system down to unit level. It also enables full-system simulation in the office (e.g., a harvester with a terminal and a dozen ECUs).
As most patterns, Hexagonal Architecture introduces additional complexity: some indirections through the adapters. This little disadvantage is far outweighed by its many advantages.
I'll explain Hexagonal Architecture in detail in this talk. You can then see for yourself why it should be the standard architecture not only for Qt embedded applications, but also for Qt applications in general.
Mobile devices are limited twofold: computational-wise and energy-wise. Making software running fast can be a challenge since we are not allowed to use brute-force multithreading that can be used in data centers. In this talk, we give an overview of performance optimization techniques for mobile devices. For data lookup operations, the memory performance will be crucial, and we will give an overview of techniques you can use to speed up data lookup. For data processing operations, the CPU performance is typically a bottleneck, and we give an overview of optimization techniques that you can use to speed up data processing.
Per default, the standard library containers allocate their memory with new and release it with delete. These calls
• do not have deterministic execution times
• can lead to memory fragmentation
In many embedded applications this is not tolerable. Therefore, using standard library containers is not allowed.
With the allocators available since C++17 in the std::pmr namespace (polymorphic memory resources) these disadvantages can often be avoided. With the pmr containers, standard library containers can be used for the first time in the history of C++ in many embedded applications.
And we can start an IoT project just by buying electronic boards which are more affordable, downloading an IDE and writing code. This way, developers improve themselves and gain more great motivation. So affordability, accessibility, and wide usage make the Embedded world/IoT a good choice if C++ developers want to improve their skills. But how to get into the embedded world, to build IoT projects and improve our skills?