DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Please enter at least three characters to search
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Last call! Secure your stack and shape the future! Help dev teams across the globe navigate their software supply chain security challenges.

Modernize your data layer. Learn how to design cloud-native database architectures to meet the evolving demands of AI and GenAI workloads.

Releasing software shouldn't be stressful or risky. Learn how to leverage progressive delivery techniques to ensure safer deployments.

Avoid machine learning mistakes and boost model performance! Discover key ML patterns, anti-patterns, data strategies, and more.

Related

  • Is Agile Right for Every Project? When To Use It and When To Avoid It
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • 7 Effective Conflict Resolution Strategies for Software Development Teams
  • Seamless Security Integration Strategies in Software Development

Trending

  • Concourse CI/CD Pipeline: Webhook Triggers
  • Medallion Architecture: Why You Need It and How To Implement It With ClickHouse
  • Mastering Advanced Traffic Management in Multi-Cloud Kubernetes: Scaling With Multiple Istio Ingress Gateways
  • DGS GraphQL and Spring Boot

The Fail-Fast Principle in Software Development

If and when your program fails, sometimes it's best to just...let it. Here's how to pick up the pieces after you've stemmed the bleeding.

By 
Dat Hoang user avatar
Dat Hoang
·
Jan. 05, 18 · Opinion
Likes (7)
Comment
Save
Tweet
Share
67.8K Views

Join the DZone community and get the full member experience.

Join For Free

The Context

Systems should not fail, applications should not crash. That’s what we all want. However, sometimes it fails, and crashes, and we all try hard to prevent that from happening.
There are a lots of ways we can to prevent softwares from failing:

  • Delay the failure.

  • Workaround when the failure happens so that software continues to work.

  • Fail silently.

Yet, there is a principle in software development that go exactly the opposite ways: Fail-fast.

What Is Fail-Fast?

Human tends to make mistakes, and software tends to have bugs. The only code that has no bugs is the code that has never been written.

Then what can we do about it?

Preventing something from failing while it’s going to fail doesn’t solve anything. It does not solve the problem, it just hides the problems. And the longer it takes for the problems to appear on the surface, the harder it is to fix and the more it costs.

And in reality, system failures and software crashes are not the worst, and sometimes they’re not bad at all. There is something much worse: deadlocks, crashes long after the original bug, data loss and corruption, and data inconsistency. If a part of the system fails or the application crashes right before those worse things happens, then we’re lucky enough.

That’s why the fail-fast principle encourages us to fail fast and early: If an error occurs, fail immediately and visibily. If something unusually or unexpectedly occurs, let the software fail immediately instead of postponing the failure or working around the failure.

Why Fail-Fast?

Fail-fast makes bugs and failures appear sooner, thus:

  • Bugs are earlier to detect, easier to reproduce and faster to fix.  

  • It’s faster to stabilize softwares.

  • Fewer bugs and defects will go into production, thus leading to higher-quality and more production-ready software.

  • The cost of failures and bugs are reduced.

The longer it takes for a bug to appear on the surface, the longer it takes to fix and the greater it costs.

Image title

Application of Fail-Fast

Fail-fast is the principle behind many Agile practices:

  • Test-driven development: Writing tests to cover all the cases in which it would fail and all the requirements it has to meet, before even implementing it.

  • Continuous integration: An Agile practice in software development, where developers are required to integrate their current works into shared repository/branch several times a days. Each integration is verified by an automated builds, thus helping team to find and fix problems early.

Other Examples of Fail-Fast

  • When there is missing environment variable or start-up parameters, instead of still starting up the system normally or using fall-back strategy (fall-back to default environments/parameters), the system should fail and stop so that we can be notified and fix the problem right away.

  • When a client sends a request with invalid parameters, instead of silently correct the parameters and continue handling the request, the server should let the request fail so that client can be notified and fix the problem as soon as possible.

  • Exceptions should never be silently swallowed. Exceptions should only be caught when the catcher know how to handle it; otherwise, let the exception be thrown outside. And let the app crash if no part of the app knows how to handle it (An exception caused by unexpected bugs).

Software development

Opinions expressed by DZone contributors are their own.

Related

  • Is Agile Right for Every Project? When To Use It and When To Avoid It
  • Breaking Bottlenecks: Applying the Theory of Constraints to Software Development
  • 7 Effective Conflict Resolution Strategies for Software Development Teams
  • Seamless Security Integration Strategies in Software Development

Partner Resources

×

Comments
Oops! Something Went Wrong

The likes didn't load as expected. Please refresh the page and try again.

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends:

Likes
There are no likes...yet! 👀
Be the first to like this post!
It looks like you're not logged in.
Sign in to see who liked this post!