Edge Cases: A Persistent Dilemma

by Jason Withrow

One of the first “lessons learned” for novice programmers is that the time required to program the typical usage scenarios can be fairly accurately estimated, but the time required for edge cases can exceed even their most generous estimates. Edge cases represent usage scenarios outside of what is generally anticipated and range from being somewhat uncommon to very rare.  They could be an unanticipated user interaction, such as copying/pasting from an Excel spreadsheet into a text box, rather than typing into it, and pasting fails to trigger an auto-saving mechanism or brings in invalid characters not available via keyboard input that derails auto-saving.  Or the edge case could be desired functionality that simply does not exist but is needed on occasion by a particular user or role.

Eliminating edge cases entirely is never going to happen; users will approach software in ways that cannot be fully anticipated, and specifications are never 100% accurate or complete, because stakeholders do not have a perfect understanding of their needs (and needs also change over time).  Such limitations have helped to drive interest in agile methodologies, but agile approaches have not eliminated edge cases and they could even create more opportunities for them to occur, as the focus shifts to smaller units of work and creating something that works, even if the code is not robust.  Since methodology isn’t making much headway, what can be done to help programmers write code that handles more edge cases or can be adapted more readily to address an edge case?

Crystallized and Fluid Intelligence

Psychologists have spent a significant amount of time and effort studying human intelligence and memory.  One of the classifications in human intelligence is between crystallized intelligence and fluid intelligence.  Crystallized intelligence is the wisdom that accumulates with age – the facts one has learned through study and experience.  Fluid intelligence, on the other hand, does not deal with concrete facts or specific lessons learned.  Rather, fluid intelligence is the capacity to problem-solve, to think abstractly and reason through situations.   In the context of software design / programming, design thinking and creativity are heavily impacted by fluid intelligence as well.

Writing robust code that already addresses some edge cases (such as the copy/paste example cited earlier) and can be scaled relatively easily to add new functionality, requires both crystallized and fluid intelligence.  Crystallized intelligence provides the foundation of good coding practices necessary for code to be robust and scalable, while fluid intelligence allows one to predict some of the edge cases as the code is being written.

Training Programmers to Better Address Edge Cases

Building crystallized intelligence rapidly is difficult; it takes time to learn a programming language and to gain life experience.  For novice programmers it may be best to explore design patterns and other “heuristics” (best practices), as well as engaging in code reviews with more senior programmers.  While there is no substitute for lived experience, it is possible to start from a more informed place by leveraging best practices and the advice of others.

Improving fluid intelligence often comes down to games: strategy board games, video games, escape rooms, role-playing games, etc.  What these all have in common is forcing one to problem-solve and think strategically.  The games do not need to be related to programming or software development; they just need to build critical analysis and problem-solving skills, as well as strengthen divergent thinking so one can arrive at novel solutions.  Once those have been strengthened, they will be applicable across a wide range of domains.  And if the games allow for cooperation and are played with members of the same development team, there may be additional benefits in the areas of teamwork and communication.

Stout Systems is the software consulting and staffing company Fueled by the Most Powerful Technology Available: Human Intelligence®. Stout was founded in 1993 and is based in Ann Arbor, Michigan. Stout has clients across the U.S. in domains including engineering, scientific, manufacturing, education, marketing, entertainment, small business and, yes, robotics. Stout provides expert level software, Web and embedded systems development consulting and staffing services along with direct-hire technical recruiting and placements. If you're looking for a job in the tech industry, visit our job board to see if you qualify for some of our positions. Best of luck to you! If you're looking to hire technical talent for your company, please contact us. This is a technical article catered to developers, technical project managers, and other technical staff looking to improve their skills. Sign up to receive our technical articles in your email inbox.

info@stoutsystems.com
877.663.0877
© Copyright 1995-2021 - STOUT SYSTEMS DEVELOPMENT INC. - All Rights Reserved
envelopephone-handsetlaptop linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram