Is there a systematic, step-by-step approach to help junior developers improve their awareness/senses of edge cases?
There are some low hanging fruits that are easy to explain and demonstrate. For example, boundary-value analysis [1], division by 0, removal of an item from an empty container, etc. However, sometimes it feels more like art than science (i.e. I know it when I see it. ).
Any feedback and/or idea is greatly appreciated. Thank you.
*1: Borrowed from Dick Guindon's "Writing is nature's way of telling us how lousy our thinking is."
[1]: https://en.wikipedia.org/wiki/Boundary-value_analysis
Later ask “are there any other edge cases?” and let them work a while longer.
Repeat as appropriate.
Let them find them on their own for a while or two.
Let them miss them on their own for a while or two.
At the right time ask “have you thought about this potential edge case?”
If you want someone to learn to deal with edge cases, they need to see it is something you value and give them time to learn how to do it.
And how not to do it. “Not” in the logical sense not “not” in a punishment sense or job evaluation sense.
Edge cases are hard and everyone screws them up. The context needs to be safe enough that people can own their mistakes and learn something other than to hide their ignorance.
Good luck.
For example, if you're building a financial system maybe ask if a negative balance is allowed. If you charge a fee based on balance (like using basis points), can the fee be negative or is there a set floor? A negative fee sounds stupid, which is why the business probably wouldn't mention it in requirements, but it would be important to set the floor at $0 so if a negative balance occurred, we wouldn't issue a fee.
On a higher abstraction layer, iff you can filter for low-bullshit, some social justice stuff can indeed help someone master the main skills needed to spot diverse failure modes in different user stories. For example, this principle is useful: https://thingofthings.wordpress.com/2014/11/15/the-curb-cut-...
One should know about all versions of null and empty or overflowed, about stuff being too big, about operations being performed out of sync.
Maybe, the easiest is to ask yourself: What can go wrong? on every line of the code.