Edge case

From HandWiki
Short description: Problem or situation that occurs only at an extreme operating parameter


An edge case is a problem or situation that occurs only at an extreme (maximum or minimum) operating parameter. For example, a stereo speaker might noticeably distort audio when played at maximum volume, even in the absence of any other extreme setting or condition.

An edge case can be expected or unexpected. In engineering, the process of planning for and gracefully addressing edge cases can be a significant task, and yet this task may be overlooked or underestimated.

Some common causes of edge cases[1] are:

  • Unpredictable user behavior
  • Evolution of use cases (e.g. user behavior may change over time)
  • Limited test coverage
  • Product complexity (for instance, in distributed systems or microservice architectures)
  • Resource limitations (e.g. limited processing power, computer memory, or computer storage)
  • Other external causes

Some basic examples of edge cases include:

  • A long username in an app overflows and displays incorrectly
  • A booking system does not handle reservations correctly on a leap day (February 29th)

Non-trivial edge cases can result in the failure of an object that is being engineered. They may not have been foreseen during the design phase, and they may not have been thought possible during normal use of the object. For this reason, attempts to formalize good engineering standards often include information about edge cases.

Software engineering

In programming, an edge case typically involves input values that require special handling in an algorithm behind a computer program. As a measure for validating the behavior of computer programs in such cases, unit tests are usually created; they are testing boundary conditions of an algorithm, function or method. A series of edge cases around each "boundary" can be used to give reasonable coverage and confidence using the assumption that if it behaves correctly at the edges, it should behave everywhere else.[2]

For example, a function that divides two numbers might be tested using both very large and very small numbers. This assumes that if it works for both ends of the magnitude spectrum, it should work correctly in between.[3]

Programmers may also create integration tests to address edge cases not covered by unit tests.[4] These tests cover cases which only appear when a system is tested as a whole. For example, while a unit test may ensure that a function correctly calculates a result, an integration test ensures that this function works properly when integrated with a database or an external API. These tests are particularly relevant with increasing system complexity in distributed systems, microservices, and Internet of things (IoT) devices. With microservices in particular, testing becomes a challenge as integration tests may not cover all microservice endpoints, resulting in uncovered edge cases.[5]

Other types of testing which relate to edge cases may include load testing and negative/failure testing. Both methods aim at expanding the test coverage of a system, reducing the likelihood of unexpected edge cases.

In test-driven development, edge cases may be determined by system requirements and accounted for by tests, before writing code. Such documentation may go inside a product requirements document after discussions with stakeholders and other teams.

See also

References

  1. Beram, Shehab (2023-08-03). "What is an edge case? Meaning, examples in software development" (in en-US). https://blog.logrocket.com/product-management/edge-case-software-development/. 
  2. Zimmerman, Josh (2012). "Unit Testing". Principles of Imperative Computation. cs.cmu.edu. https://www.cs.cmu.edu/~rjsimmon/15122-s13/rec/07.pdf. 
  3. Cho, Shinil (October 2018), "The Fourier transform", Fourier Transform and Its Applications Using Microsoft EXCEL® (IOP Publishing), doi:10.1088/978-1-64327-286-3ch2, ISBN 978-1-64327-286-3, http://dx.doi.org/10.1088/978-1-64327-286-3ch2, retrieved 2022-02-17 
  4. Khorikov, Vladimir (2019) (in en). Unit Testing: Principles, Practices, and Patterns. Manning Publications. pp. 188-190. ISBN 978-1617296277. 
  5. Hossain, Md. Delowar; Sultana, Tangina; Akhter, Sharmen; Hossain, Md Imtiaz; Thu, Ngo Thien; Huynh, Luan N. T.; Lee, Ga-Won; Huh, Eui-Nam (2023-06-23). "The role of microservice approach in edge computing: Opportunities, challenges, and research directions". ICT Express. doi:10.1016/j.icte.2023.06.006. ISSN 2405-9595. https://www.sciencedirect.com/science/article/pii/S2405959523000760.