C++ Software Design: Design Patterns – 6. Liskov Substitution Principle

C++ Software Design: Design Patterns - 6. Liskov Substitution Principle

Original Book Cover: Guideline 6: Adhere to the Expected Behavior of Abstractions (Guideline 6: Follow the Expected Behavior of Abstractions) Reading Notes: 1. Explanation • Good abstract design should not establish inheritance relationships solely based on “what it is” but should judge based on “whether the behavior is consistent”. Subclasses must be able to seamlessly … Read more

Implementing a Generic Queue in C: It’s That Simple!

Have you ever wondered how that cup of Luckin coffee you order every morning is still served in order, even when dozens of people are placing orders at the same time? Or how the 12306 ticketing system handles thousands of concurrent requests while still ensuring first-come, first-served? The answer is simple: Queue. Today, we are … Read more

Opaque Pointers and Interface Encapsulation in C Language

• 1. Overview • 2. Concept of Opaque Pointers • 3. Why Opaque Pointers are Needed • 4. Implementation Methods • 5. Complete Example: Linked List Implementation • 6. Advanced Applications: File Handles • 7. Interface Design Principles • 8. Common Pitfalls and Solutions • 9. Performance Considerations • 10. Summary of Best Practices 1. … Read more

Embedded C Language: Cohesion and Coupling

1 Principles Low coupling refers to making modules as independent as possible. While it is impossible for modules to have no connections, the interfaces between modules should be minimal and simple. Thus, high cohesion from the internal characteristics of each module in the entire program, and low coupling from the relationships between various modules in … Read more

In-Depth Analysis of Key Debouncing Techniques in Embedded Development

In-Depth Analysis of Key Debouncing Techniques in Embedded Development

Modern embedded devices are highly advanced, with embedded systems interacting with external human-machine interfaces. Currently, touch screens are popular, and even in the wave of AI, compact embedded devices can directly accept voice input for AI recognition, allowing a simple phrase like “Old Wu, please help me with xxx” to suffice. However, in scenarios requiring … Read more

Why Do Embedded Software Developers Prefer to Encapsulate Source Code into Libraries?

Why Do Embedded Software Developers Prefer to Encapsulate Source Code into Libraries?

I am Lao Wen, an embedded engineer who loves learning.Follow me to become even better together! 1. Benefits of Encapsulating into Libraries If a device program is perfectly encapsulated into a library, it means: 1. The cost for all engineers to port or create the device driver is minimal. 2. As the number of users … Read more

In-Depth Guide to Modular Programming in C: From Basics to Advanced Practices

In-Depth Guide to Modular Programming in C: From Basics to Advanced Practices

Audio Guide: Image Guide: Article Structure: 1 Basics of Modular Programming 1.1 Core Concepts and Advantages of Modularity Modular programming is a software design paradigm that focuses on breaking down large, complex programs into a series of independent and interactive functional modules. Each module is dedicated to solving a specific sub-problem and communicates with other … Read more

Issues with Poor Structures/Strategies in Railway Safety Embedded Software: Revisiting Data Lifetime Problems

Issues with Poor Structures/Strategies in Railway Safety Embedded Software: Revisiting Data Lifetime Problems

This article aims to briefly address the often-discussed issue of data lifetime under the topic of poor structures/strategies in safety software, as it is fundamental and important, and indeed a recurring problem. However, it has turned into a longer discussion. Since this section only raises issues, the logic cannot be considered rigorous. The data lifetime … Read more

Top Ten Best Practices for Designing and Implementing C++ Classes

Top Ten Best Practices for Designing and Implementing C++ Classes

From WeChat Official Account: DeepNoMind Author: Yu Fan C++ code offers sufficient flexibility, making it challenging for most engineers to grasp. This article introduces ten best practices to follow for writing good C++ code and provides a tool at the end to help analyze the robustness of C++ code. Original text: 10 Best practices to … Read more

Embedded C Language Programming

Embedded C Language Programming

The Relationship Between .h Files and .c Files When referring to the programs of experts, I found that the strict programs written by others all include a “KEY.H” file, which defines the functions used in the .C file, such as Keyhit(), Keyscan(), etc.The .H file is a header file, probably meaning ‘Head’, which is necessary … Read more