Efficient Learning of Common C++ Design Patterns

Efficient Learning of Common C++ Design Patterns

Content from: Programmer Lao Liao https://www.bilibili.com/video/BV1s5WVz9EwN/ Chapter 1: Singleton Pattern (C++) The description of the Singleton pattern is: Ensure that a class has only one instance and provide a global access point to that instance. The most important characteristic of the Singleton pattern is: A class can have at most one object. Intent: Ensure that … Read more

Comparison of Communication Methods Between Embedded System Modules

Comparison of Communication Methods Between Embedded System Modules

Follow our official account to keep the embedded knowledge flowing! 1. Global Variables Global variables are often regarded as “bad design,” but in embedded systems, they are the most performant communication method. The key is not to avoid their use, but rather to design them correctly. The issue with global variables is not performance, but … Read more

In-Depth Analysis of the C++ Visitor Pattern: Structure, Advantages, Disadvantages, and Application Scenarios

In-Depth Analysis of the C++ Visitor Pattern: Structure, Advantages, Disadvantages, and Application Scenarios

1.Introduction In C++ design patterns, the Visitor Pattern is a type of behavioral design pattern whose core idea is to separate data structures from data operations, allowing new operations to be defined without modifying existing object structures. This pattern is particularly suitable for scenarios where the data structure is stable but operations change frequently, such … Read more

C++ Design Patterns

C++ Design Patterns

Introduction In the development process, as the amount of project code increases, the difficulty of maintenance and extension gradually rises. How to design the structure of the code to decouple it, facilitate extension and maintenance, and ease team collaboration is a significant challenge. Design patterns were proposed to address this issue. The design patterns built … Read more

Essential Techniques for Embedded Development: A Practical Guide to the Strategy Pattern, Say Goodbye to If-Else Hell!

Essential Techniques for Embedded Development: A Practical Guide to the Strategy Pattern, Say Goodbye to If-Else Hell!

In the previous article, we shared about bufferevent | Embedded Network Communication Buffer Layer, where bufferevent utilizes the Strategy Pattern design, implementing polymorphic behavior through <span>struct bufferevent_ops</span>: Different types of bufferevent (such as socket, filter, SSL) share the same set of interfaces, calling their respective implementation functions through the <span>be_ops</span> pointer. This article will share … Read more

QT C++: Generalized Plugin Management System

QT C++: Generalized Plugin Management System

Designing a generalized plugin management system is crucial for large software. Below, we will combine code structure, design patterns, and architecture diagrams to provide line-by-line comments and functional interpretations of each core component, helping to understand how the system achieves high cohesion and low coupling in plugin management through code. 1. Plugin Interface Definition (<span>IPlugin.h</span>) … Read more

Understanding C++ Polymorphism: Implementation Principles and the Role of Virtual Function Tables

Understanding C++ Polymorphism: Implementation Principles and the Role of Virtual Function Tables

When you write Base* ptr = new Derived(); ptr->func(); in your code, have you ever stopped to think: how does the compiler know to execute the func() of the Derived class instead of the Base class? Clearly, the pointer type is Base, yet it can accurately find the implementation in the derived class — this … Read more

Five State Machine Design Patterns for Embedded Systems

Five State Machine Design Patterns for Embedded Systems

“ State machines are a key tool in embedded system development, allowing complex logic to be broken down into clear states and transition rules. This article introduces the core elements, five implementation patterns, and code examples, along with recommendations for pattern selection to help developers efficiently create reliable embedded systems.“ 01 — Introduction to State … Read more

The Savior of Embedded Misoperations: An Elegant One-Click Undo Solution!

The Savior of Embedded Misoperations: An Elegant One-Click Undo Solution!

1. Command Pattern The Command Pattern is a type of behavioral design pattern that encapsulates requests as independent objects, allowing users to parameterize client objects and supporting advanced features such as request queuing, logging requests, and undo operations. The Command Pattern includes the following main roles: Invoker: Requests the command object to execute the request, … Read more

C Embedded Programming Design Patterns

C Embedded Programming Design Patterns

Content Summary · · · · · · “C Embedded Programming Design Patterns” re-examines embedded systems from an object-oriented perspective and comprehensively summarizes common and critical design patterns in embedded systems. This book proposes many novel design patterns, providing powerful tools for embedded system developers using the C programming language. Through these patterns, developers can … Read more