Fang Haoming's Engineering Blog and Docs

website·Indexed 30 days ago

http://fanghaoming.dpdns.org/

A collection of engineering methodologies, technical guides, and study notes. Topics include problem decomposition, Docker fundamentals, monorepo tool selection (Nx, Lerna), Node.js interview experiences, and dynamic programming templates.

Tokens
6.3K
Snippets
6
Records
56
Agent score
50%

What's inside Fang Haoming's Blog

  1. Apply First Principles to resolve framework-level issues

    When framework-specific behavior (e.g., React components not updating) is inexplicable, revert to the 'First Principles' of the web to find the root cause. Key fundamental concepts include:

    • HTTP and URLs
    • HTML and CSS Cascade
    • DOM and JavaScript Event Loop
    • Browser Rendering Pipeline
    • Caching and Same-Origin Policy
    • Accessibility

    Example: If a React component doesn't update, check for reference stability (mutation), incorrect key usage, closure staleness, or asynchronous callback timing.

  2. Define the role of a high-level frontend engineer

    A proficient frontend engineer's value extends beyond writing pages. The core capability is the ability to:

    1. Place complex problems into a structured framework.
    2. Transform uncertainty into testable hypotheses.
    3. Convert verification results into informed decisions.
    4. Codify problem-solving experiences into stable, repeatable engineering systems.
  3. Engineering competency framework for frontend and software developers

    High-level engineering capability is defined by the ability to transform complex problems into structured systems. This involves a multi-dimensional skill set applicable across frontend, backend, client, algorithm, testing, and architecture roles. In a frontend context, these capabilities manifest in browser management, UI development, state handling, API integration, performance optimization, build processes, deployment, and collaboration.
    CategoryCompetency Dimensions
    CognitiveProblem Decomposition, Abstraction & Modeling, First Principles, System Boundary Awareness
    AnalyticalStructured Analysis, Hypothesis & Verification, Root Cause Analysis, Observability Thinking
    DesignInterface Contract Thinking, State Machine Thinking, Defensive Design, Layered Abstraction, Complexity Management
    DecisionTrade-offs & Decision Making, Risk Control, Constraint Optimization, Cost-Benefit Analysis
    EvolutionContinuous Correction, Evolutionary Design, Human-Computer Collaboration, Decision Logging, Standardization & Scaling, Antifragility
  4. Optimize deliverables under project constraints

    Engineering is not about pursuing perfection with infinite resources, but making correct trade-offs under constraints. Common constraints include time, manpower, performance, compatibility, design fidelity, SEO, security, maintainability, and business priority. The goal is to find a deliverable solution that balances ideal architecture with immediate needs (e.g., using static configuration and core components for a tight deadline while preserving the structure for future CMS integration).
  5. Core competency framework for software engineers

    Software engineering excellence across roles (Frontend, Backend, Client, Algorithm, Testing, Architecture, Product) relies on a set of cross-functional cognitive and technical capabilities. For frontend engineers, these are applied specifically to browsers, UI, state management, APIs, performance, build systems, deployment, and collaboration.
    CategoryCompetency Dimensions
    CognitiveProblem Decomposition, Abstraction & Modeling, First Principles, System Boundary Awareness
    AnalyticalStructured Analysis, Hypothesis & Verification, Root Cause Analysis, Observability Thinking
    DesignInterface Contract Thinking, State Machine Thinking, Defensive Design, Layered Abstraction, Complexity Management
    DecisionTrade-offs & Decision Making, Risk Control, Constraint Optimization, Cost-Benefit Analysis
    EvolutionContinuous Correction, Evolutionary Design, Human-Computer Collaboration, Decision Logging, Standardization & Scaling, Antifragility
  6. Optimize deliverables under project constraints

    Engineering is not about pursuing perfection with infinite resources, but making correct trade-offs under limited resources. When faced with constraints such as time, manpower, performance, compatibility, SEO, or security, the goal is to find a deliverable solution rather than ignoring the constraints. For example, if a page must launch tomorrow, prioritize static configuration and core components over a full CMS integration and A/B testing, while maintaining a structure that allows for future CMS integration.
  7. Understand Docker core concepts and architecture

    Docker is a containerization platform used to develop, distribute, and run applications by packaging them with all dependencies into a standardized container. Key characteristics include being lightweight (sharing the OS kernel), cross-platform (Linux, Windows, Mac), and providing isolation between containers and the host.
  8. Compare Nx and Lerna for monorepo management

    When choosing a monorepo tool, the decision depends on the project's complexity and primary goals.

    Nx is best for complex architectures, microservices, and projects requiring high development efficiency. It provides intelligent task scheduling, distributed caching for build/test results, code generators (e.g., for React, NestJS), and graphical dependency analysis. However, it has a higher learning curve.

    Lerna is best for simpler projects focused on library development and multi-package publishing (e.g., lerna publish). It is easier to learn but lacks native task scheduling and caching mechanisms, and has a declining community ecosystem compared to Nx.

    Recommendation:

    • For library development and publishing: Use Lerna.
    • For microservices or complex architectures: Use Nx.
    • For a hybrid of both: Nx and Lerna can be used together.
  9. Establish API contracts for frontend-backend collaboration

    Stability in collaboration depends on a strict contract (Schema First/Design by Contract). A contract must define more than just field names; it should include:

    • Data types and nullability
    • Enum values and default values
    • Error codes and pagination/sorting rules
    • Compatibility strategies and field deprecation methods. Focusing on boundary values and exception paths prevents bugs that occur when the backend changes data types (e.g., number to string).
  10. Perform structured performance analysis using a layered framework

    Use a structured approach (based on MECE/Issue Tree) to ensure performance troubleshooting is exhaustive and non-overlapping. Instead of focusing on a single slow function, analyze across these dimensions:

    LayerFocus Areas
    NetworkResource size, request count, caching, CDN
    BuildBundle size, code splitting, tree shaking
    RenderingLayout, paint, composite, long tasks
    DataAPI latency, duplicate requests, concurrency control
    InteractionInput latency, animation stutter, scrolling performance
    BusinessUnnecessary data or component loading
  11. Model UI logic using State Machine thinking

    Frontend UIs are essentially state machines. Explicitly modeling states prevents conflicting conditional logic. Instead of a simple 'data' vs 'no data' binary, consider states such as:

    • Initializing, Loading, Success, Empty, Error, Retrying, Partial Success, Permission Denied, Offline, and Stale Data.