The Artima Developer Community
Sponsored Link

Java Buzz Forum
Debugging code - the hard way

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Ben Hosking

Posts: 208
Nickname: hoskinator
Registered: Apr, 2006

Ben Hosking is Java Developer with about 5 years experience and interest in OO
Debugging code - the hard way Posted: Jun 6, 2006 6:38 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Ben Hosking.
Original Post: Debugging code - the hard way
Feed Title: A Funny Java Flavoured Look at the World
Feed URL: http://businesslogs.com/WebLog/RSS.xml
Feed Description: The blog looks at using Java and programming in general as it pops up in life as a Java programmer. It will have links to interesting Java articles and resources. It will also have a lot of SCJP Java 1.5 information and links as I am currently studying
Latest Java Buzz Posts
Latest Java Buzz Posts by Ben Hosking
Latest Posts From A Funny Java Flavoured Look at the World

Advertisement

I have spent the whole day debugging, it makes value unit tests (junit) even more than usual.

Debugging is such a difficult job when you can only test the code through the front end and checking the extra logging you have put in. The main problem I have with the code I was debugging was that it was using a struts action and almost all of the code was in the main method in the action. This basically meant it was practically impossible to test the code without using the front end and clicking and then reading the log files.

I have done a bit of refactoring but because it took me soooooo long to actually find where the problem was and then why it was going wrong, I am only doing a bit and to be honest it works and it's an action, which is pretty much self contained so it's not that much benefit refactoring it.

Today was a classic case of "everytime you fix a bug you are in danger of adding another bug" which I blogged about earlier
blog entry The bug I am fixing today wasn't in the release a couple of releases ago. We found this out by my idea of setting up a running copy of the last few releases so we can easy test the code the different customers are seeing. Anyway the code works fine there so this at least gave me some clue where to start the search on what might be causing the bug. The code was actually a result of someone fixing another bug.

The bug was also quite sneaky because it was a base class that was changed the bug has filtered up which meant it was very tricky to find.

I find bug fixing can be quite boring and frustrating, especially when you are doing it like I was today by using logging messages. I must have wasted loads of time adding comments, recompiling the servlet and stopping/starting Tomcat and then running the program.

The plus side of debugging is that you do get to know the code in detail and sometimes it's quite nice not having to write to much code. Although I do get the feeling of restlessness and like I haven't really done much that day.

The best reason I heard why you should write unit tests is

"you know how long it will take to write a unit test, how long does debugging take"

Read: Debugging code - the hard way

Topic: How to get rid of popups on Windows Previous Topic   Next Topic Topic: Symantec Anti-Virus Software Exposes Computers to Hackers

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use