• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to become an expert in troubleshooting Java errors

 
justin smythhe
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had the opportunity to see to Java developers at work. They had about 2 years experience.
I saw that they could troubleshoot many errors with ease. How can I become half as good as them?
Please do not say that it will come with experience. I know that part already. But is there a way to learn
troubleshooting, besides by experience ? I feel so frustrated when my work is stopped for 2-3 days due
to some common error which my experienced buddies solve in 10 minutes.


 
Paul Clapham
Sheriff
Posts: 21416
33
Eclipse IDE Firefox Browser MySQL Database
  • Likes 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, it's the experience. But you want a quick tip? Okay, here it is:

Read the error messages and believe what they say.

I find it amazing, the number of people who post their problems on internet forums with error messages which describe the problem exactly, and then ask what their problem is. Half of the battle in fixing bugs is understanding what you're looking at.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34965
378
Eclipse IDE Java VI Editor
  • Likes 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can gain experience faster by recognizing patterns. When you see an error, write it down. That way you remember it the next time you see it. Also fiddle with something that works. Create an error, read the message and remember it. This is easier when you know the problem.
 
Martin Vajsar
Sheriff
Posts: 3752
62
Chrome Netbeans IDE Oracle
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
  • RubberDucking does wonders. (I don't have a rubber duck on my desk, so I use my colleagues instead. )
  • Learn to create Short, Self Contained, Correct Examples. This is actually very similar concept. Very, very, very useful.
  • Remember the golden rule of debugging: if the problem does not make sense, it's two (or more) bugs combined.

  • I also like the "write it down" part of Jeanne's advice. More than once I was bugged by a persistent problem which I was not able to solve easily, but when I found the solution I didn't note it down. Sometime later I've bumped into it again. Aaaaaaargh!
     
    Randall Twede
    Ranch Hand
    Posts: 4481
    3
    Java Python Scala
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    no advice, just a ray of hope. after a while some will become so easy you won't believe it.
    symbol not found...you misspelled it or didn't import it
    array index out of bounds... usually off by one
    etc.
     
    Paul Clapham
    Sheriff
    Posts: 21416
    33
    Eclipse IDE Firefox Browser MySQL Database
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Another technique that I found useful in the past was to try explaining my problem to my boss. It didn't matter that my boss had no idea what I was talking about and indeed wasn't even competent to read the code, what eventually happened was something like this:

    Me: And then it does <whatever> and... Oh. Now I see what was wrong.

    This worked even better when the boss would play along and ask stupid uninformed questions, because often one of them would undermine an assumption I had been making all along.
     
    Randall Twede
    Ranch Hand
    Posts: 4481
    3
    Java Python Scala
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    excellent Paul. my best friend knows nothing about computers at all but still lets me bounce my thoughts off him. a true friend
     
    Jesus Angeles
    Ranch Hand
    Posts: 2068
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Troubleshooting can happen in different phases of your coding.

    If it is a new one, and you dont have logs, add logs. Make your code more testable and modularized (which is what you should do anyway).

    If it is an existing application and it doesnt give proper logs, or for example, the system simply hangs, add more logs. There are some scenarios like in jni where you run out of memory or something, and it just hangs giving no clue at all, but dumps something in your desktop.

    Wasting 2 days on an error happens to everyone. The difference to the experienced one is, if he is already hours or too long into it, he accepts that he needs help. He can dig deeper, ask google, etc.
     
    chris webster
    Bartender
    Posts: 2407
    33
    Linux Oracle Postgres Database Python Scala
    • Likes 1
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Some great advice there from wiser heads than mine - I'm sold on RubberDucking!

    Just one tip from me: take a break and go do/think about something else. It's amazing how often, when you return to your desk after a coffee break or (even better) a relaxing weekend, you can take one look at your code and say straight away "Ah, that's where the problem is!".
     
    James Boswell
    Bartender
    Posts: 1051
    5
    Chrome Eclipse IDE Hibernate
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Also, don't try to do it all on your own. That is what a development team is all about. If you get truly stuck, explain the problem/exception to a colleague. Chances are, they may have seen the problem before, know of a change to the application that may have introduced the bug or simply shed different light on it.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic