Tagged articles
defensive programming
39 articles · Page 1 of 1

21CTOOct 7, 2026 · Industry Insights
Computer pioneer Margaret Hamilton, who led the MIT team that developed the Apollo guidance software and coined the term 'software engineering,' died at 90; her defensive programming and priority-driven scheduling saved the Apollo 11 landing and laid foundations for modern software reliability.
Apollo programMITMargaret Hamilton
0 likes · 12 min read

The article explains Go's zero‑value concept, why every variable gets a deterministic default, provides a complete table of zero values for basic and composite types, shows how standard library types are "zero‑value useful", demonstrates designing your own zero‑value-friendly types, and discusses nil semantics, new vs make, and common pitfalls with practical code examples.
Godefault initializationdefensive programming
0 likes · 21 min read

This article presents ten practical Java clean‑code techniques—from meaningful naming and single‑purpose methods to avoiding magic numbers, writing purposeful comments, proper logging, defensive programming, DTO separation, Stream API usage, Optional handling, and safe ThreadPoolExecutor configuration—each illustrated with concrete code examples and explanations.
Clean CodeDTOJava
0 likes · 12 min read

The article outlines practical expert guidance for improving enterprise system reliability and security, covering architecture reviews, risk matrices, change management, continuous monitoring, incident response plans, one‑click escape mechanisms, security perimeter defenses, detection, leakage prevention, compliance, and ongoing security operations.
System Reliabilitydefensive programmingincident-response
0 likes · 11 min read

This article compiles ten practical code snippets and command patterns—from Go error handling and Git workflows to defensive programming tricks—that Tencent engineers rely on daily, helping developers build muscle memory for common tasks.
BackendDevOpsGit
0 likes · 5 min read

Learn how to use Unicode zero‑width characters as hidden watermarks in web content, encode employee IDs into plain text, detect leaks with a simple JavaScript tool, and understand the encoding/decoding process, limitations, and removal methods for this low‑cost defensive technique.
JavaScriptdefensive programmingfrontend security
0 likes · 8 min read

This comprehensive guide explains defensive programming concepts, core principles, practical rules, and advanced techniques—showing how to validate inputs, handle exceptions, manage resources, use immutability, and apply system‑level patterns like circuit breakers and rate limiting to build robust, maintainable Java applications.
Best PracticesError HandlingJava
0 likes · 26 min read

This article explains why defensive programming is essential, outlines its core principles, presents common failure scenarios and practical guidelines, and shows how testing and observability can turn inevitable errors into controlled, recoverable events that keep systems stable and maintainable.
Error Handlingdefensive programmingobservability
0 likes · 9 min read

This article explains why defensive programming is crucial for production‑grade Spring Boot 3 applications and presents eight concrete patterns—ranging from Optional‑based NPE safety and collection handling to configuration validation, async management, transaction control, testing, exception handling, circuit‑breaker integration, and reactive programming—each illustrated with real‑world code examples and best‑practice recommendations.
Backend DevelopmentBest PracticesJava
0 likes · 15 min read

This article explains why top tech companies forbid the loose equality operator (==) in JavaScript, detailing its unpredictable implicit type coercion, contrasting it with strict equality (===), and showing common pitfalls and safer alternatives for robust, maintainable code.
== vs ===Strict EqualityType Coercion
0 likes · 5 min read

A new Java developer caused a production NullPointerException while matching third‑party data, and the article walks through reproducing the bug, analyzing each faulty line, and applying defensive programming techniques such as early returns, Optional, Objects.equals, and collection checks to prevent similar crashes.
NullPointerExceptionObjects.equalsOptional
0 likes · 6 min read

A junior Java developer encounters a NullPointerException while integrating third‑party data into a Spring Boot backend, and the article walks through reproducing the bug, analyzing each faulty line, and presenting defensive‑programming, ternary, Optional, and utility‑class solutions plus a SonarLint recommendation.
NPEOptionaldebugging
0 likes · 6 min read

This article explains defensive programming as a proactive coding paradigm that anticipates and mitigates errors through input validation, error handling, assertions, and continuous testing, and demonstrates its application with detailed Java examples covering pagination, loop safety, exception management, and boundary checks.
Error HandlingJavaSoftware Robustness
0 likes · 15 min read

This article introduces defensive programming, explains its fundamental concepts and core principles such as risk identification and input validation, and demonstrates practical applications through multiple Java code examples covering pagination, loop prevention, exception handling, boundary checks, and assertions to improve software robustness.
Best PracticesError HandlingSoftware Robustness
0 likes · 13 min read

Defensive programming is a proactive coding paradigm that anticipates errors and exceptions, emphasizing input validation, error isolation, assertions, thorough testing, and clear error handling, with practical examples ranging from pagination parameter checks to loop safeguards, illustrating how to enhance software robustness and stability.
Error HandlingJavaSoftware Robustness
0 likes · 16 min read

This article explains MyBatis dynamic SQL, recounts a first‑hand OOM incident caused by missing backend validation, and shares practical lessons on parameter checking, balancing reusable versus specialized interfaces, and adopting defensive programming to build more reliable backend systems.
Dynamic SQLMyBatisOOM
0 likes · 11 min read

The article explains how defensive programming extends beyond simple input checks to include comprehensive data validation, parameter verification, illegal data handling, and collaborative design practices that protect systems from both code errors and external misuse.
API designcode qualitydefensive programming
0 likes · 7 min read

This article presents a real-world Java backend case where null pointer exceptions arise during data matching and batch insertion, analyzes the root causes in each code line, and offers defensive programming, ternary, Optional, collection checks, and utility methods to safely handle null values.
NullPointerExceptionOptionalcollection-utils
0 likes · 5 min read

This article discusses the proper use of null‑checking in Java, distinguishes between valid and invalid null returns, proposes alternatives such as returning empty collections, using assertions or throwing exceptions, and demonstrates the Null Object pattern with concrete code examples while also noting related community resources.
JavaNull Objectdefensive programming
0 likes · 9 min read

Java developers constantly battle NullPointerExceptions, a historic flaw introduced by Tony Hoare, but modern JDKs provide clearer messages and defensive techniques—such as explicit null checks, utility methods, avoiding null returns, and using Optional—can dramatically reduce these runtime errors.
BackendError HandlingJava
0 likes · 6 min read

The article explores the notorious Java NullPointerException, its historical roots in Tony Hoare's introduction of null, modern JDK 14 diagnostic improvements, and practical defensive programming techniques—including explicit null checks, avoiding null returns, and leveraging Optional—to write safer, more robust code.
Java8NullPointerExceptionOptional
0 likes · 6 min read

This article revisits defensive programming, explores quirky variable‑naming techniques—including single‑character, Chinese, and multilingual identifiers—and humorously breaks down core OOP concepts while stressing the developer’s irreplaceable role in modern software projects.
JavaOOPdefensive programming
0 likes · 7 min read

Tencent’s team successfully took over a 93‑service legacy content architecture, stabilizing it by building comprehensive monitoring, creating detailed code walkthrough documentation, fixing critical bugs, and streamlining R&D processes, which cut daily alerts from 159 to zero, reduced business incidents, and lowered on‑call staffing dramatically.
CI/CDSystem Monitoringalert governance
0 likes · 24 min read

This article walks through a real Java NPE incident, reproduces the faulty code, analyzes each null‑pointer cause, and presents defensive programming, Optional, and utility‑method solutions, while also recommending the SonarLint plugin for early detection of such bugs.
JavaNullPointerExceptionOptional
0 likes · 6 min read

This article presents a real-world Java backend case where a newly hired developer caused a NullPointerException during data matching and batch insertion, analyzes each line of the problematic code, and offers defensive programming techniques such as null checks, Optional, and utility methods to avoid NPEs.
Backend DevelopmentJavaNullPointerException
0 likes · 5 min read

This article walks through a real‑world NPE incident in a Java SpringBoot service, demonstrates how four lines of code can cause three null‑pointer exceptions, and provides practical defensive‑programming solutions such as early returns, ternary checks, Optional, and utility methods to eliminate these bugs.
JavaNPENull Safety
0 likes · 6 min read

This article walks through a real production NPE incident in a Java backend, reproduces the faulty code, analyzes each null‑pointer cause, and presents defensive programming, ternary, Optional, and utility‑library solutions while recommending SonarLint for automatic detection.
JavaNPEOptional
0 likes · 6 min read

The article outlines defensive programming concepts, emphasizing input validation, error handling, resource management, isolation techniques, and design considerations such as thread safety, cache strategies, and interface versioning to build robust and resilient software systems.
Error HandlingSoftware Robustnessdefensive programming
0 likes · 4 min read

This article explains defensive programming for front‑end developers, covering its definition, the three pillars of prevention, correction and direction, common UI and code crisis points, detailed code‑review checklists, CSS defensive rules, and responsive design considerations to build resilient, user‑friendly applications.
CSS best practicesError HandlingUI resilience
0 likes · 30 min read

This article examines the challenges of repetitive if‑else parameter checks, introduces Hibernate Validator as a JSR‑303 implementation, demonstrates how to build a reusable validation module, and shares best‑practice patterns for integrating elegant, decoupled validation into Java backend systems.
Backend DevelopmentHibernate ValidatorJSR-303
0 likes · 10 min read

This article explains why excessive null‑checking in Java code is problematic, distinguishes between cases where null is a valid response and where it signals an error, and shows how returning empty collections or applying the Null Object pattern can eliminate redundant checks.
best-practicesdefensive programmingnull pointer
0 likes · 7 min read

This article explains how to write robust Java code by applying defensive programming techniques such as guard clauses, proper exception handling, validator usage, assertions, and the DRY principle, while illustrating each concept with clear code examples and practical guidelines.
DRY principleException HandlingJava
0 likes · 20 min read

The article explains how defensive programming in Java—using guard clauses, validators, and side‑effect‑free assertions—prevents errors, outlines proper exception handling by distinguishing checked from unchecked exceptions, and reinforces the DRY principle, urging developers to abstract repeated logic after three occurrences.
DRY principleException HandlingJava
0 likes · 18 min read

This article explains how to write robust Java code by applying defensive programming, using guard clauses, proper exception handling, validator patterns, assertions, and the DRY principle, offering concrete code examples and practical advice for building reliable software.
DRY principleException HandlingJava
0 likes · 19 min read

The article explores how adopting a "don't trust" mindset—through rigorous input validation, defensive coding, thorough testing, gradual rollouts, and comprehensive monitoring—helps build resilient, high‑performance systems and avoid common pitfalls in development and operations.
System Reliabilitydefensive programmingdeployment
0 likes · 13 min read

The article explores defensive programming and contract programming, discussing how to handle unexpected JSON data, the role of assertions and exceptions, and the trade‑offs between strict error handling and contractual code design for building robust software.
Error Handlingassertionscontract programming
0 likes · 8 min read


21CTOFeb 8, 2016 · Fundamentals
This article explains defensive programming concepts for PHP developers, illustrating why anticipating failures, never trusting user input, avoiding assumptions, maintaining narrow focus, and keeping consistent syntax can dramatically reduce bugs and improve code reliability.
Coding Best PracticesError HandlingPHP
0 likes · 8 min read

After two decades of coding, the author shares ten defensive, often‑considered paranoid Java programming practices—such as placing constants on the left side of equals, guarding against NullPointerExceptions, treating -1 as a valid index, using final for methods, variables, and parameters, and handling switch statements—to promote more robust code.
BackendParanoid Codingdefensive programming
0 likes · 7 min read

To avoid NullPointerException in Java, use string literals with equals, prefer String.valueOf over toString, employ null‑safe libraries like Apache Commons StringUtils, return empty collections instead of null, annotate with @NotNull/@Nullable, prevent unnecessary autoboxing, define sensible defaults, and use Jackson's path method for safe JSON navigation.
Apache CommonsJacksonJava
0 likes · 5 min read
