I have a pretty robust workflow for developing in Notebooks. One element of that workflow is the reflexive habit of saying
ClearAll just before a definition so that experimental definitions don't linger and fool me during iterative, interactive development. For example, suppose I define
foo[x_] := bar[x];
and then later, I decide to change the definition. I overwrite the above with
foo[xs___] := baz[xs];
foo to forget about
bar. But I get a surprise. While
foo[1, 2] produces
foo produces the old
bar. If I had
ClearAll[foo]; foo[x_] := bar[x];
ClearAll[foo]; foo[xs___] := baz[xs];
I wouldn't have had the surprise. Obviously, this can be really important in big, complex definitions with many cases and branches all intertwined and infeasible to track in your head, so it's a routine habit and I don't even think about it any more.
The question is whether the same habit should pertain to Package development. I never see
ClearAll before definitions in the Packages I've read, but wouldn't it make sense for the same reason as it does in Notebooks? Or is there some other development fu technique that I don't know about for Packages? Or do people only publish completely finished, formally certified & debugged Packages, and they never need to do iterative development on them ever again (tiny sarcasm)? Or, is there special magic in the Package system that clears symbols on a package reload? Perhaps the subcontexts are automatically discarded?
In short, why don't I see ubiquitous
ClearAll in Packages?