My first impression:
Put your comments above the line they refer to, and make sure no line exceeds 80 lines. This is a mess to look at and try to comprehend. Nevertheless, I shall try, so I can make constructive remarks.
[I used to do mine like that but i found it made the code very long...]
Next thing I notice:
Your conditionals. Sometimes you use braces, and sometimes none. Choose a consistent style, since it makes disambiguation much easier.
[See point 1]
Structure your code such that you're not just using static methods and fields exclusively. Have the user of the code create and work with instances of the Debug class. Which reminds me... if you do that... choose a noun name for your class.
[I purposely did that to make it easier and more available to beginers who dont know about creating objects of classes
, although keeping static objects to a minimum is better (which I normally try to do)]
Having to send a special string to toggle the value of a field seems very hackish. Wouldn't it be better to just have a method which does that?
[Now that is a good idea, i can't believe i didnt think of that]
// we limit to last 300 entries because dos has 300 line max[/code]
You're using a language which can run on many platforms. It should not be crippled just because Windows is.
[Well, Windows is the most common OS, I used that OS, and i wanted to give some explaination for why I did that]
You might add a PrintWriter field to your class, so that output can be directed anywhere, rather than just standard out.
[Will do if I think of it next time that code gets opened, thx, and maybe a method to email programmer with debugging record]
Don't use the adding to an empty string hack to convert primtive types to strings. Use something like:
code: |
Integer.toString(num) |
[Bah, whats the fun in that ... maybe if i have time... this code originated as a method from my Pegs game which had only string support, i later added more and ability for other types so i could post it here (rather rushed) because i thought it would be useful to some, after stubling upon the project for the Turing debug library project from 2003]