crazy debugging idea
Oct. 17th, 2006 03:17 amWhen debugging, we sometimes observe information being transformed on the GUI, and we want to know *WHO* is doing that processing. Say, you want to find out who is sorting the string "d-f-a" into "a-d-f".
If you don't know the source that well (which is always the case in large enough projects), this can be very time-consuming.
My solution:
Write a script to modify ALL methods in your source that take strings. The script will add to the beginning of these methods the following code:
for each method
*Even* if you forget to back-up your code, the prints are very easy to remove, since they all have string "//CRAZY-DEBUGGER" in them.
But this is only a hack towards my general goal: transparency between code and interface. Mapping visual properties (i.e. the user's concepts) into variables (i.e. the programmer's concepts) should be automatic.
Am I the only one with this dream?
If you don't know the source that well (which is always the case in large enough projects), this can be very time-consuming.
My solution:
Write a script to modify ALL methods in your source that take strings. The script will add to the beginning of these methods the following code:
if (s.equals("d-f-a")){ //CRAZY-DEBUGGER
System.out.println("foo: s = " + s); //CRAZY-DEBUGGER
} //CRAZY-DEBUGGERfor each method
foo and string s in the list of arguments. For methods taking two strings, the scripts adds the above code twice.*Even* if you forget to back-up your code, the prints are very easy to remove, since they all have string "//CRAZY-DEBUGGER" in them.
But this is only a hack towards my general goal: transparency between code and interface. Mapping visual properties (i.e. the user's concepts) into variables (i.e. the programmer's concepts) should be automatic.
Am I the only one with this dream?
(no subject)
Date: 2006-10-17 04:00 am (UTC)(no subject)
Date: 2006-10-17 11:42 am (UTC)(no subject)
Date: 2006-10-17 04:31 pm (UTC)(no subject)
Date: 2006-10-17 04:32 pm (UTC)(no subject)
Date: 2006-10-17 05:28 pm (UTC)(no subject)
Date: 2006-10-17 06:40 pm (UTC)(no subject)
Date: 2006-10-17 08:42 pm (UTC)(no subject)
Date: 2006-10-18 04:55 am (UTC)I'm not sure induction priciples are relevant here, but I thought of the phrase and decided to use it anyway.
(no subject)
Date: 2006-10-17 04:13 am (UTC)(no subject)
Date: 2006-10-17 06:58 am (UTC)This is probably not the same as what you want. :-)
(no subject)
Date: 2006-10-17 07:00 am (UTC)(no subject)
Date: 2006-10-17 01:41 pm (UTC)a) Learn to use the log4j package ( http://logging.apache.org/log4j/docs/index.html ), it does exactly what you want to do. You can download and study its source code. Knowing log4j is a must for every Java programmer that works with J2EE - it is THE standard.
b) If you're using JDK 1.4 or later, and you really want to write your logging class, you can use the class java.lang.StackTraceElement (check the javadoc). It is easier to use than the method that Log4J used for determining the method and class - it is because Log4J must run in older JDK versions.