To learn a programming language, you must first learn how to debug.
-
My Programming Laws
-
Recently I started working on python language, at some point, exception is thrown with only a single error message, i.e. no stack trace logs. This is normally caused by accessing attribute of a None object. A safe programming technique will be using try-catch scope but legacy codes may not always in the ideal shape.
So based on the production logs available, we have to use fuzzy logic strategies to find common point and narrow the scope to pinpoint cause of issue.
Strategies of Debugging Exception
-
Stacktrace
exception with stack trace logs will pinpoint the cause of issue. -
Logging flow
flow of log messages may tell where is the possible scope of issue. -
Keyword
searching for specific keyword from the logs will also help to narrow the scope. -
Commit compare
if this issue just happened in this current version, we can compare the codes diff. -
Invocation trace
back-trace the route of method calls (backward probably to the class it inherit).
-
-
Thumb of rule: A well-designed module is defined how the easy it can be unit tested.