Edge Cases: Dealing With the Unexpected


One of these things are not like the others


Today's post is inspired by a minor problem I encountered in an automated solution.

An unaccounted-for scenario arose, much like the winds that famously brought down the Tacoma Narrows Bridge, leading to an unexpected result.

After examining the input values used in the calculation, I pinpointed the cause of the error. This experience made me appreciate what my university lecturers were trying to instill in us: always account for edge cases.

A friend of mine had a motto—he aimed to make his code 'monkey-proof,' ensuring that even nonsensical input wouldn't break his program.

I believe that building resilient solutions should always be the goal, especially for systems intended for reuse.

By considering as many edge cases as possible from the outset, you'll make your solutions far more maintainable in the long run.

Now, here are some ways to find edge cases:

Know Your Ranges

What is the expected range of values for your data? Consider the extremes, such as the smallest and largest possible values. Are there any values that might be invalid or cause unexpected behavior?


Validate Formats

If your data has a specific format (e.g., dates, email addresses), ensure you validate it to prevent errors.

Think Outside the Box

Consider unusual scenarios that might not be immediately obvious. For example, if your code is handling dates, think about leap years, time zone differences, or cultural variations in date formats.


Integration Testing

 Test how your code interacts with other components of your system to identify potential edge cases at the system level.


Resources

 

Comments

Popular posts from this blog

Missing Data : What to Do?

Prompt Engineering : An Introduction

Upskilling: Certificates vs. Certifications

Women In STEM : Challenges and Advantages

SQL Server Reporting Services vs. Power BI

5 Authentication Methods

There Has Been a Data Breach: Now What?

Inductive and Deductive Reasoning

Improving SQL Query Performance : Indexes

Don't Be Bland : Spice Up Your Personal Brand