AI 资讯
Left of the Loop: The Metron
Metron was the Greek word for a measure: the standard you judge a thing against. It gives us metric, and metronome. Pick the wrong metron and everything you count against it comes out wrong, no matter how carefully you count. Ask most teams how they know AI adoption is working, and the answer is some version of: we’re shipping more. More PRs, more tickets closed, more velocity on the board. None of those numbers were ever measuring what people thought they were measuring. They were proxies, and bad ones, for whether the team was creating value. AI didn’t break that. It just made the proxies lie louder. An agent can produce PRs faster than any team can review them. It can close tickets all day. None of that tells you whether the thing built was worth building, or whether it fixed the actual problem, or whether anyone downstream is better off. Burning tokens isn’t the same thing as creating value. It just looks the same on a dashboard built to reward the first thing. The same DORA numbers I pointed at earlier are blunt about it: individual output climbs while delivery throughput and stability drop. Same bottleneck, counted at the wrong end . This is Theory of Constraints in one sentence: speeding up a step that wasn’t the bottleneck doesn’t speed up the system. It just piles more work in front of whatever the real bottleneck is. Implementation used to be the constraint. Now it isn’t. Review is. Coordination is. Making sure everyone agrees on what “done” even means is. Agents made the fast part faster and left the slow part exactly where it was, except now it’s buried under more output arriving to be reviewed by fewer people who understand any of it. Measuring individual speed after that shift is measuring the wrong clock. The team can be faster and worse off in the same quarter. The instinct, when this gets noticed, is to add another skill to the agent. Automate the review step too. Automate the coordination. Whatever’s slow, throw a capability at it. That doesn’t fix
开发者
C++ Optimized Compilation Ways
The very common way we know to compile a C++ program is by running the following command: g++ filename.cpp -o filename Talking in terms of stages of optimized compilation, this method is the basic one — we can say stage 0, also written as: g++ -O0 filename.cpp -o filename There are a few more, from zero to three. Let's talk about these ways of compilation. 1] -O0 : No Optimization (Default) Fast compile time. Every variable gets a real stack slot; nothing gets reordered or removed. 2] -O1 : Basic Optimization Some dead code elimination. Simple register allocation. 3] -O2 : 'Standard' Optimization Register allocation. Dead code elimination. Inlining small functions. Loop unrolling and vectorization. Constant folding/propagation. Does not enable optimizations that trade accuracy/safety for speed. 4] -O3 : More Aggressive than -O2 Sometimes faster, sometimes not. Can hurt cache performance. Other than this, there is also a space-optimization option. 5] -Os : Optimization for Size Instead of Speed The command to use these optimizations is as follows: g++ -O2 filename.cpp -o filename Remember, in -O2 the "O" is a capital letter, not a zero — the same applies to the other optimization levels. If you don't know what's going on, or you just wish to compile C++ files the way developers do, use the following standard command: g++ -O2 filename.cpp -o filename
AI 资讯
Navigating Intellectual Property as a software Developer.
What I learned at Zone01 Kisumu's IP training Introduction Yesterday, I attended an Intellectual Property training at Zone01 Kisumu, and it fundamentally changed how I think about the code I write. As developers, we spend countless hours building software, but how many of us truly understand the value of what we create,and how to protect it? In Kenya's rapidly growing tech ecosystem, understanding IP isn't just a legal nicety, it's a competitive advantage. Whether you're building an app, contributing to open source, or launching a startup, knowing your rights can mean the difference between owning your work and losing it. This article breaks down the essential IP frameworks every software developer should know. What is Intellectual Property in Software? Intellectual Property (IP) in software encompasses legal protections designed to safeguard the rights of creators and developers. The four primary types of IP protection relevant to software are: patents, copyrights, trademarks, and trade secrets . Copyright: Protecting Your Code Copyright is the most immediate form of protection for software developers. In Kenya, copyright protection arises automatically at the moment of creation,registration is not mandatory . This means that when you write code, you automatically own the copyright to that expression, provided the work is fixed in a tangible medium . However, a crucial distinction exists: copyright protects the expression of ideas, not the ideas themselves . This principle was reinforced in the Kenyan case of Solut Technology Limited v Safaricom Limited, where the court confirmed that without access to source code, it's difficult to prove infringement because the "expression" (the code itself) wasn't shared . Key Insight: Registering your copyright with KECOBO in Kenya provides prima facie evidence of ownership and can make enforcement faster if someone copies your work . Patents: Protecting Functionality While copyright protects the expression of code, patents pro
AI 资讯
Why Expensive Software Development Never Looks Expensive
Every organisation that has run a significant software system for more than a few years has felt a version of the same thing: a change that should have taken days takes months, nobody can quite explain why, and the explanation that eventually gets offered — the domain is complex, the requirements changed, the previous team was careless — is almost never checked against an alternative approach for the software architecture or alternative framework choices, because the alternative was never built. There is no possible comparison to determine the solution chosen is a good one and there is no benchmark to measure "fit for purpose." This is the unfalsifiability problem, and it is worth stating plainly before anything else in this piece, because it is the reason the cost described below is so rarely traced back to its actual cause. Every system is built once. There is no version of your platform built the other way, running alongside it, that anyone can compare it to. So when a system works, the approach that produced it gets read as validated. When a system becomes expensive to change, the cost gets attributed to anything except the structural decision that caused it — because that decision was made years ago, by people who may have moved on, and there is no control group to prove that the structure was the variable that mattered. That absence of a control group is not a minor academic point. It is the reason a specific, avoidable pattern of cost has been able to spread through the industry for decades, get taught in courses, get validated in interviews, and still never be clearly named as a mistake. This article is an attempt to name it — and to offer something more useful than a diagnosis: a way to check, this week, whether it applies to you. The Villain: Process Over Product Ask almost any team building a significant piece of software what the goal of the project is, and the honest answer, more often than anyone would like to admit, is not "build the best-fitting prod
AI 资讯
Every HTTP Status Code Tells a Story
Every time you open a website, sign into an application, or send a request to an API, a server responds with a small but powerful message: an HTTP status code. Most developers encounter these codes every day. But behind every number is a story about what happened between the client and the server. HTTP status codes are part of a standardized response system defined by RFC 9110. They help applications understand whether a request succeeded, needs attention, or failed. The HTTP Status Code Families 🟢 2xx — Success The request was received, understood, and completed successfully. Examples: 200 OK — The request succeeded. 201 Created — A new resource was successfully created. These responses tell the client: everything worked as expected. 🔵 3xx — Redirection The requested resource requires an additional step. These responses help clients find another location or use a different version of a resource. Examples include redirects and cache-related responses. 🟠 4xx — Client Errors Something is wrong with the request sent by the client. Common examples: 400 Bad Request — The request format is invalid. 401 Unauthorized — Authentication is required. 403 Forbidden — The client does not have permission. 404 Not Found — The requested resource does not exist. In simple terms: the problem is usually on the client side. 🔴 5xx — Server Errors The request was valid, but the server failed while processing it. Example: 500 Internal Server Error — An unexpected error occurred on the server. These responses indicate problems within the server or its internal systems. Why HTTP Status Codes Matter HTTP status codes are not just numbers. They are: The language of web communication Essential signals for API behavior Valuable tools for debugging and monitoring A foundation of backend engineering and distributed systems Understanding status codes helps developers build better applications, diagnose problems faster, and design more reliable systems. A single three-digit number can reveal what ha
AI 资讯
The Architecture of Presence: A Manifesto for Embodied AGI
I. The Terminal Velocity of Disembodied Intelligence The current paradigm of artificial intelligence is approaching a fundamental cognitive ceiling. We have built vast, sprawling minds, yet we have trapped them in sensory deprivation chambers. Today’s Large Language Models and industrial robotics operate under a fatal flaw: the reliance on linear, arbitrary tokenization. Traditional AI chops raw text into disconnected, non-semantic fragments, wasting immense computational memory tracking the mere phonetic order of spelling and grammar. Simultaneously, industrial machines navigate the physical world through siloed sensor pipelines. They process light, space, and kinetics as heavy, raw digital arrays, relying on brute-force algorithmic equations to stitch reality together. This is not intelligence; it is computational exhaustion. To achieve true artificial general intelligence, the machine must stop reading about the world and begin to inhabit it. II. The Biological Imperative Nature solved the hardware-software integration problem millions of years ago. Human biology remains the ultimate benchmark for flawless, metabolic efficiency. Our somatosensory system does not wait for a central brain to read a text string before pulling a hand away from a fire; it processes physical feedback in milliseconds through decentralized neural highways. Human cognition leverages cross-modal integration within the angular gyrus, allowing visual data to be instantly cross-referenced with kinesthetic feedback to trigger anticipatory motor reflexes. Furthermore, biological intelligence is inherently tied to physical survival. We manage thermodynamics through a centralized hypothalamic thermostat, protecting the body from cellular destruction, while routing ambient light data to deep-brain structures to drive a natural circadian rhythm. True AGI requires this exact synthesis of abstract thought and biological mechanics. III. The Logographic Paradigm Shift To bridge the gap between
AI 资讯
Hundreds rally at Bethesda HQ to protest Xbox layoffs, and Ars was there
Union wants to halt a "perpetual cycle" of layoffs, get back to contract bargaining.
AI 资讯
The Future of Rust: Dominating Systems Programming in 2026
The Future of Rust: Why This Memory-Safe Language is Dominating Systems Programming in 2026 In its early years, Rust was often viewed as a "rising star"—a promising language with significant potential but a steep learning curve. As we navigate through 2026, that narrative has fundamentally shifted. Rust has transitioned from a niche interest to a cornerstone of modern, memory-safe infrastructure. The language is no longer just proving its worth; it is defining the gold standards for systems programming, cloud-native backend services, and kernel development. This deep dive explores the key pillars driving Rust's evolution, its massive ecosystem growth, and the roadmap for the years ahead. Seamless Ownership: The New Era of Rust Ergonomics One of the most significant shifts in recent Rust development has been the relentless focus on language ergonomics. Historically, developers occasionally felt that custom smart pointers were "second-class citizens" compared to built-in references. The "Beyond the & " initiative has successfully bridged this gap. Through advancements in Smart Pointer Parity , developers can now use custom pointers—such as Rc , Arc , or specialized interop pointers—with the same intuitive syntax and capabilities as standard references. Furthermore, the introduction of sophisticated field projection mechanisms and &own references allows for unprecedented precision in managing ownership and borrowing. This makes complex data structures much easier to implement and reason about, drastically reducing the friction typically associated with high-level abstractions. The Async Revolution: Making Asynchronous Code Natural Rust has achieved a milestone often referred to as "Async Parity," aiming to make asynchronous programming feel as natural and seamless as synchronous code. Several key developments have fueled this revolution: Async-in-Traits: The stabilization of async fn in traits has removed the need for external crates like async-trait , greatly simplify
AI 资讯
Five Local-First Mac Apps I Built to Fix Everyday Workflow Problems
Over the last few months, I’ve been turning small workflow problems I encounter on my Mac into focused utilities. Rather than building one enormous productivity suite, I wanted each app to solve a specific frustration well. I also wanted to build software the way I prefer to use it: local-first, available through a one-time purchase, and usable without creating another account or paying for another subscription. Here are five of the apps I’ve built so far. ScreenShelf My desktop used to become a temporary storage zone for screenshots, folders, documents, links, and files I needed for active projects. Folders helped with long-term storage, but they were not always useful for things I wanted to keep visible and nearby. ScreenShelf creates a customizable visual shelf for: Files and folders Screenshots and images Links Text Applications Frequently used project materials You can organize items across separate pages, customize the appearance of each page, and keep different groups of materials available for different projects. It also includes a Recents area that surfaces recent screenshots, which is helpful when the small screenshot preview disappears before you can interact with it. ScreenShelf is essentially the space between a cluttered desktop and a deeply nested folder system. Learn more about ScreenShelf PopNote Some reminders are too small for a full task-management system. You might need to remember to send a file in twenty minutes, check something after lunch, or complete one small step before ending the day. PopNote is a lightweight menu bar app that creates timed pop-up reminders on your Mac. The reminders appear as small visual bubbles rather than traditional notification banners. You can choose a time, add an icon, and let the note reappear when you need it. It is designed for temporary reminders that should remain noticeable without becoming another project to organize. Learn more about PopNote File Fetch I frequently download, save, rename, copy, and move
AI 资讯
I Read 500+ GitHub Issues About AI Agents. We Keep Solving the Wrong Problems.
Everyone talks about prompts memory RAG But production issues were actually loops false completion replay retries wrong tool non deterministic execution Here are the top 7. That's what led us to build Failproof AI not because we wanted another framework, but because we kept seeing the same reliability problems across every framework.
AI 资讯
Is Being Full-Stack Really Necessary in the Age of AI?
In an AI-powered reporting project, the backend API response time suddenly jumped to 8 seconds; I couldn't find a solution by examining only the frontend code to isolate the issue. This experience highlighted how the lack of a full-stack developer, who can see API, data layer, and model integration simultaneously, can slow down a project. Below, I will analyze step-by-step whether being full-stack is truly necessary in the age of AI. Why is Being Full-Stack Necessary in the Age of AI? The primary benefit of being full-stack is enabling a single developer to have end-to-end control of AI systems. This is because training a model, saving it to a vector database, and serving it via a REST API all occur at different layers; each of these layers might require a separate area of expertise. However, a full-stack developer, by being able to see the entire process from the data collection script ( python collect_data.py ) to the model service ( uvicorn app:app --host 0.0.0.0 ), can catch integration errors faster. Let's illustrate this advantage with a concrete example: within a project, I automated model retraining using a systemd timer and saw “Active: active (waiting)” in the systemctl status model-retrain.timer output; however, the API layer's GET /predict response was still returning the old model. Identifying the issue was only possible by simultaneously examining the timer configuration and the API code; without switching between separate teams. Summary: Full-stack proficiency provides the ability to detect and resolve potential incompatibilities within the complex data-model-service chain of AI projects at a single point. How Do Full-Stack Skills Contribute to AI Projects? A full-stack developer keeps all steps, from data preprocessing ( pandas script) to the model service ( FastAPI endpoint), within a single codebase. This simplifies version control and the CI/CD workflow. For example, when I define a postgres service, a redis cache, and an api service within docker
AI 资讯
i've been building platforms first for 25 years. i think it's wrong now.
i've been that person. standing in front of leadership with an 18-month architecture diagram, explaining why we need six months of infrastructure before a user touches a single feature. and it made sense. for 25 years it made sense. writing boilerplate was expensive. every feature came with a tax — database migrations, routing config, auth wiring. build a shared platform first, pay that tax once. the roadmap justified the investment. then i saw a stat that wouldn't leave me alone. roughly 60% of features on a six-month roadmap are obsolete by launch. not slightly off. obsolete. the customer's problem shifted. the market moved. you spent six months building a precise answer to a question nobody asks anymore. the longer you invest before showing something real, the more expensive it is to admit you were wrong. so you don't. you ship the wrong thing and call it "on schedule." i've done it. i've watched it happen. AI didn't create this problem. but agents are making it impossible to ignore. the 82-point gap mckinsey's 2025 survey: 88% of organizations use AI. only 6% see real bottom-line impact. that 82-point gap isn't about tools. everyone has the same tools. but something shifted in their may 2026 report. they describe agents working overnight — enriching requirements, generating code, packaging outputs for morning review. they call it the "24-hour sprint." leading organizations see 3-5x productivity with 60% smaller teams. a product owner logs in at 9am and finds a feature went from requirements to tested code overnight. nobody worked late. agents did. that's not autocomplete. that's a different delivery model. and here's what most teams miss: it only works when the work is small, bounded, and complete. agents need to know where a task starts and ends. horizontal platform architectures don't give them that. the codebase is the prompt jeremy d. miller built wolverine for .NET. in june 2026 he wrote: "the structure of your codebase is now, effectively, part of the prom
AI 资讯
The Cohesion Series and IVP — Five Papers Published
The cohesion paper series is now published in full — five papers that build a chain from the concept of cohesion to the Independent Variation Principle (IVP) . The chain: On the Nature of Cohesion — defines cohesion as a $2k$-tuple: for $k$ partitioning rules, $k$ (purity, completeness) pairs. Proves the knowledge-embodiment theorem: maximal cohesion under a rule coincides with exact knowledge embodiment under that rule. Shows that every published algorithmic cohesion metric measures a structural proxy (method-call overlap, shared-field density), not cohesion as defined by a principle. DOI: 10.5281/zenodo.20785752 Causal Cohesion — instantiates the schema under one concrete rule — change-driver-assignment identity: elements belong together iff $\Gamma(e_1) = \Gamma(e_2)$. Develops the metric $H_\text{causal}(M) = (\text{purity}(M), \text{completeness}(M))$, a two-dimensional score that fills one slot of the $2k$-tuple. DOI: 10.5281/zenodo.20785881 Four Necessary Conditions for Optimal Modularization — from the schema plus the objective of minimizing change propagation, proves four conditions — Admissibility, Element Form, Separation, Unification — are necessary and jointly exhaustive, uniquely pinning the $\Gamma$-equality partition $E / \tilde{\Gamma}$. DOI: 10.5281/zenodo.21362420 Why Minimizing Change Propagation Minimizes Maintenance Cost — decomposes total maintenance cost into access, alignment, cognitive, and domain-fixed components. Proves that minimizing change propagation cost is equivalent to minimizing total maintenance cost under an explicit coefficient condition, justifying the objective paper 5 assumed. DOI: 10.5281/zenodo.21362542 The Independent Variation Principle — synthesizes the chain into a single structural principle and examines the premises (change drivers, functional model, change isolation), preconditions (driver independence, decisional autonomy), and scope boundary. DOI: 10.5281/zenodo.21362618 Two derivations Last month's preprint — Der
开发者
Conditional Operator (`?:`) in Java
The conditional operator ( ?: ) — The Only Ternary Operator is one of the most useful operators in Java. It lets you write simple decision-making logic in a single line, making your code cleaner and more concise. It's also a favorite topic in Java interviews because of its syntax, nesting behavior, and type compatibility rules. In this article, you'll learn: What the conditional operator is Why it's called a ternary operator Syntax and working Nested conditional operators Difference between ?: and if-else Practical examples Interview questions Memory tricks What is the Conditional Operator? The conditional operator is represented by: ? : It is the only ternary operator in Java . A ternary operator takes three operands , unlike: Operator Type Number of Operands Example Unary 1 ++x , !flag , ~5 Binary 2 a + b , a > b , a && b Ternary 3 (a > b) ? a : b Syntax result = ( condition ) ? valueIfTrue : valueIfFalse ; How It Works condition │ Is it true? / \ Yes No │ │ valueIfTrue valueIfFalse │ │ └────── Result ──────┘ If the condition is true , Java returns the value before the colon ( : ). If the condition is false , Java returns the value after the colon ( : ). Example 1 int x = ( 10 > 20 ) ? 30 : 40 ; System . out . println ( x ); Output 40 Step-by-Step Evaluate the condition: 10 > 20 ↓ false Since the condition is false, Java selects the value after : . 40 Therefore, x = 40 Example 2: Finding the Maximum int a = 10 ; int b = 20 ; int max = ( a > b ) ? a : b ; System . out . println ( max ); Output 20 This is one of the most common uses of the conditional operator. Example 3: Even or Odd int number = 7 ; String result = ( number % 2 == 0 ) ? "Even" : "Odd" ; System . out . println ( result ); Output Odd Example 4: Absolute Value int x = - 5 ; int absolute = ( x < 0 ) ? - x : x ; System . out . println ( absolute ); Output 5 Nested Conditional Operators One of the biggest advantages of the conditional operator is that it can be nested . Example int x = ( 10 > 20 ) ? 30 :
AI 资讯
Why AI Agents Are Replacing Traditional SaaS
A few weeks ago I was setting up a new project and needed to do the usual dance: create a Notion doc, spin up a Linear board, invite the team to Slack, and set up a couple of Zapier automations to connect them all. It took me most of an afternoon. That's when it hit me — I wasn't actually trying to "use" any of these tools. I just wanted the outcome. I wanted the project set up. And somewhere between the fifth Zapier trigger and the third failed webhook, I found myself thinking: why am I the one gluing all this together? That question is basically the whole thesis behind this post. AI agents aren't just a new feature category bolted onto SaaS. They're starting to eat the reason SaaS exists in the first place. The old deal: software rents you a workflow Traditional SaaS sells you a workflow, not an outcome. You pay for Notion, and Notion gives you a very nice, very rigid shape to pour your thoughts into. You pay for HubSpot, and it gives you a CRM shape. You pay for Zapier so you can awkwardly stitch the shapes together. This worked great for twenty years because the alternative was building everything yourself. SaaS was the shortcut. But the shortcut came with a tax: you had to adapt your work to fit the tool, and when you needed two tools to talk to each other, you had to become a part-time integrations engineer. The new deal: software does the workflow for you An AI agent flips that relationship. Instead of "here's a tool, go operate it," it's "here's the outcome, go figure out how to get there." You tell an agent "onboard this new client" and it can read the contract, create the folders, send the welcome email, schedule the kickoff call, and post a summary in Slack — using whatever tools it has access to, without you clicking through five different dashboards. That's the part that's easy to miss if you only think of agents as "chatbots with extra steps." A chatbot answers questions. An agent does multi-step work: It breaks a goal down into subtasks It calls tools
AI 资讯
7 MongoDB Query Mistakes That Return the Wrong Results
MongoDB queries look simple. You type a field, give it a value, hit run, and you get your data back. But just because a query runs without throwing an error doesn't mean it worked right. Sometimes you get a blank screen. Sometimes you get way too many records. Other times, the data looks fine at first glance, but it doesn't actually match what you asked for. Most of these slip-ups happen for one basic reason: the query structure doesn't match the way the data actually sits in the database. To show you what we mean, we’ll use a clinic database with a collection called visits . Here is what a typical document looks like: JSON { "_id": "6871b6f9c3f1d1a4c2a10001", "status": "completed", "visitDate": "2026-07-01T09:30:00.000Z", "patient": { "name": "Anna Keller", "age": 34 }, "doctor": { "name": "Dr. James Carter", "specialty": "Cardiology" }, "symptoms": ["cough", "fever"], "prescriptions": [ { "name": "Ibuprofen", "active": false }, { "name": "Paracetamol", "active": true } ], "invoice": { "paid": true, "method": "card", "total": 250 } } You can run these examples right in the VisuaLeaf MongoDB Shell . Using visual tools makes a big difference because you can see exactly what MongoDB is returning in real time. 1. Forgetting the Curly Braces This is just a quick typo, but it breaks things right away. The Mistake: db . visits . find ( status : " completed " ) The Correct Query The find() tool always expects an object. Even if you are only looking for one specific thing, you still need to wrap that condition in curly braces {} . 2. Treating $or Like a Regular Object This one trips a lot of people up because the broken version looks like it should work. The Mistake: db.visits.find({ $or: { status: "completed", "invoice.paid": false } }) What is wrong: $or expects an array of conditions, but this query gives it one object. The error will usually be something like: MongoServerError: $or must be an array The Correct Query The first query is wrong because $or needs an array, n
AI 资讯
ADR Template: How AI Generates Architecture Decision Records Your Future Self Will Thank You For
Teams make dozens of architectural decisions every month but document almost none of them. The rest dissolve into Slack threads, hallway conversations, and the minds of people who will leave the company within a year. Six months later, a new developer stares at the code and asks: "Why Redis here instead of PostgreSQL for queues?" Nobody remembers. An archaeological dig through Git history, Slack, and Notion begins. Two hours spent investigating a decision that originally took 15 minutes. Architecture Decision Records (ADRs) solve this problem. But they don't get written. The reason is simple: drafting an ADR takes 30-40 minutes, and the developer has already moved on to the next task. AI compresses that to 3-5 minutes. This article covers ADR structure, prompts for LLM-based generation, real-world examples, and CI pipeline automation. What ADRs are and why capturing architectural decisions matters An ADR (Architecture Decision Record) is a document that captures one specific architectural decision. Not a spec, not an RFC, not a design document. One decision, one file. Michael Nygard introduced the concept in 2011. The format took hold at large companies (Spotify, Thoughtworks, GitHub) but remains rare in smaller teams. The main reason: the writing overhead feels higher than the value it delivers. Three situations where the absence of ADRs hurts the most: Onboarding. A new developer reads the code and encounters an unconventional decision. Without an ADR, they either spend hours investigating, or treat it as a mistake and "fix" it. Both paths are expensive for the team. Revisiting decisions. Context changes: load increases, new requirements emerge, a dependency goes stale. Without a record of why the current solution was chosen and which alternatives were rejected, the team re-runs the entire analysis from scratch. Audits and compliance. In regulated industries (fintech, healthtech), architectural decisions require documented justification. ADRs close that gap automa
开发者
Stop Saying You Want Ownership Mindset
My 2nd article this week, I'm supposed to keep it to just once per week but whateverrr, I've had this...
AI 资讯
The Everyday Backend Engineer: Step 10 — The Observer Pattern
Welcome back to The Everyday Backend Engineer: Practical Design Patterns . In our last post, we made our core algorithms interchangeable using the Strategy Pattern. Today, we close out our design patterns roadmap with arguably the most native pattern in the entire Node.js ecosystem: The Observer Pattern . Let’s look at how to master event-driven decoupling to trigger secondary workflows seamlessly without bloat. 🔴 The Problem: Direct Inline Side-Effects Imagine you are writing a video processing engine or a simple order fulfillment system. When a specific event happens—such as an order being finalized—multiple unrelated departments want a piece of the action: The Notification Service needs to send an SMS and Email receipt. The Logistics Service needs to generate a warehouse fulfillment ticket. The Analytics Service needs to update marketing tracking boards. If you don't decouple these events, your primary execution service ends up managing a giant web of secondary micro-services: // ❌ Bad Practice: The primary service is drowning in secondary dependencies const EmailService = require ( ' ../services/email ' ); const WarehouseService = require ( ' ../services/warehouse ' ); const AnalyticsTracker = require ( ' ../services/analytics ' ); class OrderProcessor { async finalizeOrder ( order ) { console . log ( " Saving primary order to the database... " ); // Core business logic ends here // The codebase smell: Procedural cascading dependencies await EmailService . sendReceipt ( order . userEmail ); await WarehouseService . createShipment ( order . id ); await AnalyticsTracker . trackSale ( order . totalAmount ); } } module . exports = OrderProcessor ; Why does this slow your system down? Your core OrderProcessor is now structurally dependent on three separate systems. If the AnalyticsTracker throws a network timeout error or if the warehouse API changes its interface, your core transaction fails or hangs. Furthermore, adding a fourth side-effect (like an auditing logger
AI 资讯
The graph nobody is watching
If you ask me what part of the system I protect the most, the answer is the database. I've been writing software alone for twenty-four years, and across every platform I've built, the rule has stayed the same: the web servers can take whatever you throw at them, the batches can be rebuilt, but the database has to stay idle on purpose. Not because I love idle databases, but because the day a database actually starts to struggle is a day with very few good options. This article is about what "keep the database idle on purpose" actually means in practice, and about one particular kind of graph that, in my experience, almost nobody is watching. The three layers and what each of them gets I think of a production system as having three tiers, and each tier gets a different rule. The web server tier can be horizontally scaled. If load grows, you add machines. If something is wrong, you take a machine out of the pool, and the others handle it. Failures here are visible immediately, and they're cheap to recover from. The batch server tier can be scaled up or out depending on the work. A batch that's too slow can be split. A batch that crashes can be retried. End users don't see batch servers, so a stuck batch is a problem for me and not for them. Some headroom up here is fine. The database tier is the one I treat completely differently. The database is not where you absorb load. The database is what you protect from load. The reason is simple: the other tiers can be rebuilt or re-scaled. The database is the irreplaceable record. If it slows down, everything slows down. If it falls over, you don't have many minutes before the rest of the stack notices. So my rule for the database is: keep it idle. Not idle in the sense of "doing nothing." Idle in the sense of "running well below its capacity, at all times, so that any extra load it picks up has somewhere to go." For more than a decade I ran a large appliance-grade database where I kept the load average below 1 at all times. N