gusl: (Default)
[personal profile] gusl
When 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:

if (s.equals("d-f-a")){ //CRAZY-DEBUGGER
   System.out.println("foo: s = " + s); //CRAZY-DEBUGGER
} //CRAZY-DEBUGGER


for 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)
ikeepaleopard: (Default)
From: [personal profile] ikeepaleopard
You seem to have invented a poor man's version of aspects.

(no subject)

Date: 2006-10-17 04:13 am (UTC)
From: [identity profile] darius.livejournal.com
Totally reasonable dream. Squeak, Self, and Boxer are some systems that do better at it than the mainstream stuff.

(no subject)

Date: 2006-10-17 06:58 am (UTC)
From: [identity profile] gwillen.livejournal.com
I have a perl script which does what you ask for.

This is probably not the same as what you want. :-)

(no subject)

Date: 2006-10-17 07:00 am (UTC)
From: [identity profile] gwillen.livejournal.com
Er, actually, my script does what you ask for, for Javascript, where every function declaration matches "function .*?(.*?).*?{". Java actually having types would make that somewhat harder, but you could do it heuristically.

(no subject)

Date: 2006-10-17 11:42 am (UTC)
From: [identity profile] simrob.livejournal.com
You stole my comment!

(no subject)

Date: 2006-10-17 01:41 pm (UTC)
From: [identity profile] peamasii.livejournal.com
I found this related recommendation on the Sun Java forums:

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.

(no subject)

Date: 2006-10-17 04:31 pm (UTC)
tiedyedave: (Default)
From: [personal profile] tiedyedave
You stole my comment too!

(no subject)

Date: 2006-10-17 04:32 pm (UTC)
ikeepaleopard: (Default)
From: [personal profile] ikeepaleopard
After I stole it from you and Rob, I gave it to Gustavo. If you want it, you'll have to get it back from him.

(no subject)

Date: 2006-10-17 05:28 pm (UTC)
tiedyedave: (Default)
From: [personal profile] tiedyedave
It's about aspects. He can keep it, thanks. :-)

(no subject)

Date: 2006-10-17 06:40 pm (UTC)
From: [identity profile] simrob.livejournal.com
Can't I just rewrite the function in which you gave it to Gustavo in order to make so you gave it to me first?

(no subject)

Date: 2006-10-17 08:42 pm (UTC)
ikeepaleopard: (Default)
From: [personal profile] ikeepaleopard
I'm not implmeneted using aspects. I have proper abstraction boundaries.

(no subject)

Date: 2006-10-18 04:55 am (UTC)
From: [identity profile] simrob.livejournal.com
Curse you and your sound induction principles!

I'm not sure induction priciples are relevant here, but I thought of the phrase and decided to use it anyway.

February 2020

S M T W T F S
      1
2345678
9101112131415
16171819202122
23242526272829

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags