In a statically typed (object oriented?) language, function overloading offers the facility of organizing your code into two or more functions with different types and/or number of arguments. This is highly useful when the functionality offered by the function can be invoked in different scenarios. For instance, let us consider the function(s) below: // C# code Dictionary<string, object> CreateResponse(string msg) { return CreateResponse(ex.Message, 0, false); } Dictionary<string, object> CreateResponse(string msg, int code) { return CreateResponse(ex.Message, code, false); } Dictionary<string, object> CreateResponse(string msg, bool success) { return CreateResponse(ex.Message, 0, success); } Dictionary<string, object> CreateResponse(Exception ex) { return CreateResponse(ex.Message, ex.HResult, false); } Dictionary<string, object> CreateResponse(string msg, int code, bool success) { var errorInfo = new Dictionary<string, object>(); erro...
Another effective [debugging] technique is to explain your code to someone else. This will often cause you to explain the bug to yourself. Sometimes it takes no more than a few sentences, followed by an embarrassed "Never mind. I see what's wrong. Sorry to bother you." This works remarkbly well; you can even use non-programmers as listeners. - From "The Practice of Programming" by Brian W Kernighan & Rob Pike.