Rainmic's Programming and Design Blog

website·Indexed 29 days ago

https://rainmic1019.github.io/

A technical blog covering C++ concurrency and multithreading, design patterns, embedded Linux development, and GUI implementation using AWTK. Topics include mutexes, unique_lock, IOT.js adaptation for AWorks, Linux DRM, and MFC development.

Tokens
67.6K
Snippets
244
Records
364
Agent score
75%

What's inside Rainmic Blog

  1. Overview of the Interpreter Design Pattern

    The Interpreter Design Pattern provides a way to evaluate the grammar or expressions of a language. It defines a representation for a grammar and provides an interpreter that uses that representation to interpret sentences in the language. This pattern is particularly useful when a specific type of problem occurs frequently enough that it can be expressed as a sentence in a simple language, allowing a general interpreter to solve all instances of that problem.
  2. Overview of the Visitor Design Pattern

    The Visitor pattern represents an operation to be performed on the elements of an object structure. Its primary intent is to separate the data structure from the algorithms/operations that act upon it, allowing new operations to be defined without modifying the classes of the elements on which they operate.
  3. Overview of AWTK-MVVM Framework

    AWTK-MVVM is a C-language MVVM (Model-View-ViewModel) framework optimized for embedded platforms. It provides data binding, command binding, and window navigation, allowing developers to build applications by focusing on binding rules and model implementation without needing to learn the core AWTK API. It supports both C and JS development, though it does not natively support dynamic generation of UI elements.
  4. Overview of Windows Named Pipes

    Named Pipes provide a mechanism for reliable, unidirectional or bidirectional data communication between different processes on the same computer or across a network. Unlike anonymous pipes, named pipes have a defined name and can be accessed by multiple processes.
  5. Overview of AWTK Canvas Types

    AWTK provides two types of canvases for drawing GUI elements. The choice depends on the complexity of the shapes and the required performance:

    1. canvas (Standard Canvas): Used for simple drawing tasks such as horizontal/vertical lines, text, images, and rectangles. It is more efficient than the vector canvas.
    2. vgcanvas (Vector Canvas): Used for complex shapes like ellipses, arcs, and rounded rectangles. While more feature-rich, it has lower performance compared to the standard canvas.
  6. Overview of Service Worker in PWA

    A Service Worker is a Web API that acts as a proxy between the browser and the network. It can intercept network requests, enable offline access by caching resources, and provide background processing capabilities. Due to security requirements, Service Workers can only be used over HTTPS or on localhost.
  7. Overview of the Strategy Design Pattern

    The Strategy pattern is a behavioral design pattern that defines a family of algorithms, encapsulates each one, and makes them interchangeable. This allows the algorithm to vary independently from the clients that use it. It is particularly useful for replacing complex conditional statements (if/else or switch) with polymorphic behavior, allowing a class's behavior or algorithm to be modified at runtime.
  8. Overview of the State Design Pattern

    The State Pattern is a behavioral design pattern that allows an object to alter its behavior when its internal state changes. The object will appear to change its class. This pattern is primarily used to solve problems where an object's behavior depends on its current state (attributes), replacing large conditional blocks (like switch/case or if/else) with state-specific classes.
  9. Compare static site generators for cloud documentation

    When choosing a static site generator for technical documentation, consider the following trade-offs between VuePress, Docusaurus, and Sphinx:

    • VuePress: Minimalist, high performance, centered on Markdown. Supports Vue components for extensions. Easy environment setup (Node.js >= 8.6). Good for quick deployment of documentation with navigation and sidebars.
    • Docusaurus: Very similar to VuePress but based on React. Requires Node.js >= 12.13.0.
    • Sphinx: Powerful, originally for Python. Uses reStructuredText (rst) by default. Excellent for PDF generation (via LaTeX) and cross-referencing. However, it has a complex setup, lacks a built-in navigation bar (requires manual HTML editing), and requires plugins (like Recommonmark) to support Markdown.
  10. Implement the Template Method design pattern

    The Template Method is a behavioral design pattern used to define the skeleton of an algorithm in a base class, while deferring some specific steps to subclasses. This allows subclasses to redefine certain steps of an algorithm without changing the algorithm's overall structure.

    Key Components:

    • AbstractClass: Defines the template method (the algorithm skeleton) and abstract 'primitive operations' that subclasses must implement.
    • ConcreteClass: Implements the primitive operations to provide specific behavior for the algorithm steps.

    Usage Scenario: Use this pattern when you want to implement the invariant parts of an algorithm once and leave the variant parts to be implemented by subclasses, or when you need to control subclass extension by only allowing hooks at specific points.

  11. Convert Markdown to PDF using Pandoc and TeXLive

    Pandoc converts Markdown to PDF via a two-step process: first, it transforms the Markdown document into a LaTeX source file; second, it invokes a TeX engine (such as pdflatex or xelatex) to render that LaTeX file into a PDF document.
  12. Implement the Mediator Design Pattern

    The Mediator pattern reduces the interaction complexity between multiple objects and classes by providing a mediator class that handles communication. This promotes loose coupling, as objects (Colleagues) no longer need explicit references to one another; they only interact with the Mediator.

    Key Participants:

    • Mediator: Defines the interface for communicating with Colleague objects.
    • ConcreteMediator: Implements the coordination logic and maintains references to the Colleagues.
    • Colleague: Knows its mediator and communicates through it to interact with other colleagues.

    Common Use Cases:

    • GUI Dialogs: Coordinating interactions between buttons, text fields, and list boxes (e.g., disabling a button when a text field is empty).
    • Frameworks: The Controller in MVC or the ViewModel in MVVM act as mediators between the Model and View.