Backend Development 11 min read

Finite State Machine Based Advertisement Status Management in the LEGO Advertising Platform

This article systematically introduces a finite state machine (FSM) based solution for managing advertisement status in the LEGO advertising platform, detailing the background challenges, problem review, two design alternatives (strategy‑factory pattern and configuration‑driven approach), their advantages, disadvantages, and a final recommendation.

58 Tech
58 Tech
58 Tech
Finite State Machine Based Advertisement Status Management in the LEGO Advertising Platform

The LEGO platform, a middle‑office system of 58.com, handles online advertising across dozens of product types and billing models, making ad status management increasingly complex as the platform scales.

Problem Review: The original asynchronous task grew tangled with extensive if/else/switch logic, severe coupling between products, poor extensibility, and high maintenance cost, especially when new products are added.

Solution 1 – Strategy Pattern + Factory Pattern: This approach decomposes logic by product, using a strategy factory to obtain specific strategy implementations for each promotion. It isolates product‑specific logic, reduces coupling, and allows incremental addition of new strategies, though it may suffer from code reuse limitations.

Solution 2 – Configuration‑Driven Implementation: The system is split into five components—Trigger Center, Processing Center, Validation Center, Action Center, and Configuration Center. Each component’s rules are expressed as configurable entries (e.g., ESB01=100,200,300), enabling free combination of triggers, validations, and actions without code changes.

Comparison: Both solutions address logical complexity and coupling, but the configuration‑driven model further improves extensibility and maintainability by making all rules visible and editable in configuration files, eliminating the need for additional code when new products are introduced.

Conclusion: Based on the platform’s growth and the need for scalable, maintainable ad state management, the configuration‑driven approach (Solution 2) is selected as the final implementation strategy.

strategy patternbackend architectureconfiguration managementState MachineAdvertisementfsm
58 Tech
Written by

58 Tech

Official tech channel of 58, a platform for tech innovation, sharing, and communication.

0 followers
Reader feedback

How this landed with the community

login Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.