Interesting opinion. I pity the poor b... that have to maintain your code.

Here's some code from Sun's BigDecimal class. I guess they have a bunch of retards working there:

// should now be at numeric part of the significand
            int dotoff = -1;                 // '.' offset, -1 if none
            int cfirst = offset;             // record start of integer
            long exp = 0;                    // exponent
            if (len > in.length)             // protect against huge length
                throw new NumberFormatException();
            char coeff[] = new char[len];    // integer significand array
            char c;                          // work

            for (; len > 0; offset++, len--) {
                c = in[offset];
                if ((c >= '0' && c <= '9') || Character.isDigit(c)) {
                    // have digit
                    coeff[precision] = c;
                    precision++;             // count of digits
                    continue;
                }
                if (c == '.') {
                    // have dot
                    if (dotoff >= 0)         // two dots
                        throw new NumberFormatException();
                    dotoff = offset;
                    continue;
                }
                // exponent expected
                if ((c != 'e') && (c != 'E'))
                    throw new NumberFormatException();
                offset++;
                c = in[offset];
                len--;
                boolean negexp = false;
                // optional sign
                if (c == '-' || c == '+') {
                    negexp = (c == '-');
                    offset++;
                    c = in[offset];
                    len--;
                }
                if (len <= 0 || len > 10)    // no digits, or too long
                    throw new NumberFormatException();
                // c now holds first digit of exponent
                for (;; len--) {
                    int v;
                    if (c >= '0' && c <= '9') {
                        v = c - '0';
                    } else {
                        v = Character.digit(c, 10);
                        if (v < 0)            // not a digit
                            throw new NumberFormatException();
                    }
                    exp = exp * 10 + v;
                    if (len == 1)
                        break;               // that was final character
                    offset++;
                    c = in[offset];
                }
                if (negexp)                  // apply sign
                    exp = -exp;
                // Next test is required for backwards compatibility
                if ((int)exp != exp)         // overflow
                    throw new NumberFormatException();
                break;                       // [saves a test]
                }
            // here when no characters left
            if (precision == 0)              // no digits found
                throw new NumberFormatException();

            if (dotoff >= 0) {               // had dot; set scale
                scale = precision - (dotoff - cfirst);
                // [cannot overflow]
            }
            if (exp != 0) {                  // had significant exponent
		try {
		    scale = checkScale(-exp + scale); // adjust
		} catch (ArithmeticException e) { 
		    throw new NumberFormatException("Scale out of range.");
		}
            }
            // Remove leading zeros from precision (digits count)
            int first = 0;
            for (; coeff[first] == '0' && precision > 1; first++)
                precision--;

            // Set the significand ..
            // Copy significand to exact-sized array, with sign if
            // negative
            // Later use: BigInteger(coeff, first, precision) for
            //   both cases, by allowing an extra char at the front of
            //   coeff.
            char quick[];
            if (!isneg) {
                quick = new char[precision];
                System.arraycopy(coeff, first, quick, 0, precision);
            } else {
                quick = new char[precision+1];
                quick[0] = '-';
                System.arraycopy(coeff, first, quick, 1, precision);
            }
            intVal = new BigInteger(quick);
Member Avatar for ztini

Funny, I don't use an IDE at all and I've never needed a debugger for Java... The first time I had this sort of problem it probably did take me an hour or two to sort it out. That was good, it meant I can spot these things now without mechanical assistance.

Its a tool, its readily available, why not use it? I use Eclipse all day and the debugger just today.

We use a proxy connection to transmit xml requests and receive xml responses to a db layer and then group of library modules to translate the xml into Java. The Java code was fine, but the debugger helped me to see that the response object was translating an element as null. The issue lied with an xml descriptor. This was deep in data model of 30k lines that was interacting with another set of 100k lines. Sure this could of been discovered by manually tracing the code or hacking it up with some otu statements, but the debugger makes it so much easier...it only took a few 10 minutes to definitively isolate, reproduce, and correct the issue.

Debuggers are so useful ...not using a debugger or an IDE does not make you cool or superior or whatever ... it just makes you stupid. It's like saying...no, I don't want to drive a car 10 miles to work, I'd rather ride a bike. Maybe thats what you like and you're Amish or something and that's fine, but it makes me lol a big one as a I drive by.

Member Avatar for ztini

Interesting opinion. I pity the poor b... that have to maintain your code.

Here's some code from Sun's BigDecimal class. I guess they have a bunch of retards working there:

// should now be at numeric part of the significand
            int dotoff = -1;                 // '.' offset, -1 if none
            int cfirst = offset;             // record start of integer
            long exp = 0;                    // exponent
            if (len > in.length)             // protect against huge length
                throw new NumberFormatException();
            char coeff[] = new char[len];    // integer significand array
            char c;                          // work

            for (; len > 0; offset++, len--) {
                c = in[offset];
                if ((c >= '0' && c <= '9') || Character.isDigit(c)) {
                    // have digit
                    coeff[precision] = c;
                    precision++;             // count of digits
                    continue;
                }
                if (c == '.') {
                    // have dot
                    if (dotoff >= 0)         // two dots
                        throw new NumberFormatException();
                    dotoff = offset;
                    continue;
                }
                // exponent expected
                if ((c != 'e') && (c != 'E'))
                    throw new NumberFormatException();
                offset++;
                c = in[offset];
                len--;
                boolean negexp = false;
                // optional sign
                if (c == '-' || c == '+') {
                    negexp = (c == '-');
                    offset++;
                    c = in[offset];
                    len--;
                }
                if (len <= 0 || len > 10)    // no digits, or too long
                    throw new NumberFormatException();
                // c now holds first digit of exponent
                for (;; len--) {
                    int v;
                    if (c >= '0' && c <= '9') {
                        v = c - '0';
                    } else {
                        v = Character.digit(c, 10);
                        if (v < 0)            // not a digit
                            throw new NumberFormatException();
                    }
                    exp = exp * 10 + v;
                    if (len == 1)
                        break;               // that was final character
                    offset++;
                    c = in[offset];
                }
                if (negexp)                  // apply sign
                    exp = -exp;
                // Next test is required for backwards compatibility
                if ((int)exp != exp)         // overflow
                    throw new NumberFormatException();
                break;                       // [saves a test]
                }
            // here when no characters left
            if (precision == 0)              // no digits found
                throw new NumberFormatException();

            if (dotoff >= 0) {               // had dot; set scale
                scale = precision - (dotoff - cfirst);
                // [cannot overflow]
            }
            if (exp != 0) {                  // had significant exponent
		try {
		    scale = checkScale(-exp + scale); // adjust
		} catch (ArithmeticException e) { 
		    throw new NumberFormatException("Scale out of range.");
		}
            }
            // Remove leading zeros from precision (digits count)
            int first = 0;
            for (; coeff[first] == '0' && precision > 1; first++)
                precision--;

            // Set the significand ..
            // Copy significand to exact-sized array, with sign if
            // negative
            // Later use: BigInteger(coeff, first, precision) for
            //   both cases, by allowing an extra char at the front of
            //   coeff.
            char quick[];
            if (!isneg) {
                quick = new char[precision];
                System.arraycopy(coeff, first, quick, 0, precision);
            } else {
                quick = new char[precision+1];
                quick[0] = '-';
                System.arraycopy(coeff, first, quick, 1, precision);
            }
            intVal = new BigInteger(quick);
if (c == '.') {
                    // have dot

Yes they do. I pity anyone who needs this kind of comment.

Yes we'd all agree that is a very poor comment.
The comment should say why we're interested in a dot at this point.

Its a tool, its readily available, why not use it?

If it increases your dependency on someone else, it's not a tool, it's a crutch. I don't say that nobody should use an IDE, but if you're learning to write code you should write the code for yourself and manage your style for yourself - eventually, when you know what you're doing, maybe you want some jerk leaning over your shoulder saying "hey, do you want this method? How about this one?" and pushing buttons for you - I hate it, but if you don't find someone pestering you to be a nuisance, go for it.

Debuggers are so useful ...not using a debugger or an IDE does not make you cool or superior or whatever ... it just makes you stupid. It's like saying...no, I don't want to drive a car 10 miles to work, I'd rather ride a bike. Maybe thats what you like and you're Amish or something and that's fine, but it makes me lol a big one as a I drive by.

Well, as it happens I live in Boston so I have no need to drive, and I notice that fat slobs in cars seem to have a lot more trouble getting around without their cars than people who eschew the gasoline-powered wheelchair, so I think your example is a good one. If you're lazy, you get fat. If you get fat, you get slow and you die young.
Sounds like a lose to me...

But returning from the metaphor, there's nothing very cool about using or not using a debugger - it's just funny that you think it's such a great tool and it never really crossed my mind to use one, because I know my code, and I know when it's broken. And if I look at your code, I can see where that's broken too - so I think it's good for me to be able to do it for myself.

But again, if you prefer fat and lazy, have a happy heart attack!

Member Avatar for ztini

Its not whether it can be done with or without a debugger -- its the efficiency of it.

Using a tool does not make you lazy. Good grief, Jon. Do you use a wind up clock for an alarm? Or when you communicate with someone do you put a letter on pigeon's foot? Or maybe you prefer to clean your clothes by washboard? If not, then you're just fat and lazy and will have a happy heart attack. Come on Jon, don't be stupid.

The comment should say why we're interested in a dot at this point.

It does:

if (dotoff >= 0) // two dots
throw new NumberFormatException();

ztini, you're the one who's saying you require tools. If using your tools makes you unable to cope without them, they're making you fat and lazy, metaphorically at least. If you don't use muscles, you lose them. If you don't remember things (like phone numbers) you lose the ability to remember (like anything at all). So I don't rely on stored numbers in my phone, and I remember numbers. If you don't practice reading code, and you let a machine do it for you, you lose the ability to do it - this does not make you write better code.

All I'm saying is - you require these things. There's a reason why you require them. I use them when I need them, the same way I'll get in a car if I have to go a long way, or I'll use a truck to move large objects from place to place, but I don't require a car to live, and I don't require a prosthetic brain to call someone on the phone, and I don't require a little elf in a box to write my code for me, and I'm happy that way.

But as I say, if your way makes you happy, go for it!

Member Avatar for ztini

Tell me Jon -- in a Java application how would you debug incoming xml encapsulated in a soap envelope that produces unexpected data? There is so much that could be wrong -- wrong xml, wrong schema, wrong wsdl, wrong data, bad marshaller, etc etc. How exactly do you debug something like that without, as you say, a mechanical tool? How would you isolate and reproduce this error efficiently without the use of a debugger? Code you did not write nor have you seen before and because its on a production server, you can't hack it up with a bunch of "out's" -- and the key word here is "efficiently".

But really, its rhetorical question -- you would never do this without some sort of debugging tool, no serious, professional developer would -- ever. A developer's time is better spent innovating and inventing, not debugging existing applications. Anything that reduces this wasted time is worth its weight in gold.

And yes, using Eclipse makes me happy. Maybe producing code by methods that are at least 15 years antiquated makes you happy?

time to stop drinking, really

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.