Urgent.News

What's breaking now, across thousands of outlets.

Tech

Design patterns aren't a catalog — they're a way to predict where change will hurt

Most design pattern content stops at "here's what a Factory is." That's fine for a quiz, but it doesn't help you when you're staring at a real codebase deciding how to structure the fifth integration you've onboarded this year. I spent a recent afternoon deliberately drilling on pattern recognition — not memorizing names, but learning to ask the right question before writing code. This post is…

Design patterns are not a mere catalog of solutions; instead, they represent a method for anticipating where changes may impact a system. In the context of integrating with multiple external partners, this perspective is particularly valuable. To illustrate this concept, consider three hypothetical partners, each with distinct requirements and data formats.

The initial approach to handling these integration challenges often involves creating a single service class with a lengthy case statement to manage partner-specific logic. However, this method quickly becomes unwieldy and difficult to maintain as new partners are added.

The key to effectively navigating this complexity lies in asking the right questions before writing code. First, determine whether a step can halt subsequent processes. If a step can stop the flow, this indicates a Chain of Responsibility pattern, where each step is independent and can terminate the entire process. For instance, in the case of partner verification checks, if any check fails, the integration should stop and not proceed to the next step or communicate with the partner's API.

This design ensures that each check operates independently and can veto the entire flow if necessary.

Second, assess whether you are adapting to an existing interface or defining your own. If you are adapting to an existing API, you are likely dealing with an Adapter pattern. In this scenario, you translate the external partner's data format into a format compatible with your application. However, if you are defining the interface yourself, allowing for interchangeable implementations, you are employing a Strategy pattern.

This pattern enables the selection of behavior at runtime, enabling the system to choose between different implementations based on the specific requirements of each partner.

Finally, examine the actions that follow a successful integration step. If these actions occur independently and without requiring coordination among each other, you are dealing with an Observer pattern. For example, after a successful account creation, multiple reactions such as logging, notifying the operations team, and updating a cache might occur. Each reaction operates independently, and none need to be aware of the others, reflecting the Observer pattern's design principle of decoupled observers.

By applying these principles, developers can avoid the pitfalls of monolithic, difficult-to-maintain code and instead adopt a design that is adaptable, scalable, and resilient to future changes. The focus should be on understanding the flow of the system and how each component interacts, rather than merely memorizing pattern names. This analytical approach ensures that the chosen patterns truly address the underlying issues, leading to more robust and maintainable codebases.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

Go GC Pauses in an RTB Bidder: Mark Assist, Deadlines, and the Rust Decision

A bidder that loses auctions on timeout while its average looks healthy is being described by the wrong number. The deadline belongs to the exchange and covers the network in both directions.

  • RTB bidder performance depends on exchange deadline and auction timeouts
  • Round trip time includes latency, connection setup, queue time, deserialization
  • Garbage collection concurrently impacts single connection performance

new Date('2026-03-01') is 28 February if your user is in California

We build a tool that turns a few form fields into a finished resignation or notice letter. The single most important string in that output is a date.

  • Function converts date string to Date object using new Date()
  • Bug arises from UTC parsing, making 2026-03-01 equal 28 February in California
  • Tool should use local construction, days-based calculations to avoid issues

More from Thursday 10 September →