How do you fix an obvious bug?
Consider the following code (from Eclipse 3.2, org.eclipse.jdk.internal.core.NamedMember):
for (int i = 0; i < length; i++) {
String typeArgument = typeArguments[i];
typeArgument.replace('/', '.');
buffer.append(Signature.toString(typeArgument));
if (i < length-1)
buffer.append(',');
}
FindBugs points out that the return value of
replace('/', '.')
is being ignored and thus the call has no effect. It is very tempting to just "fix" the code to get
for (int i = 0; i < length; i++) {
String typeArgument = typeArguments[i];
typeArgument = typeArgument.replace('/', '.');
buffer.append(Signature.toString(typeArgument));
if (i < length-1)
buffer.append(',');
}
But does this actually fix the code? We probably don't have any test cases where the type argument contains a '/', or else we would have already have fixed the code. Or perhaps the buffer should contain slashes rather than dots, and the fact that the return value from replace is ignored is what makes the code correct. Or perhaps '.' would be the correct answer, but other code in the system depends upon the error in this code.
Static analysis tools, such as FindBugs, don't actually know what your code is supposed to do. Instead, they typically just find inconsistencies in your code. Invoking a String replace method and ignoring the return value is weird or inconsistent, but we don't actually know that using the return value is more correct.
So no easy answers. On recommendation is that when you see an obvious bug, maybe you shouldn't just bang out a quick fix. Instead, figure out why tests aren't showing a problem with this code, try to document the intended behavior and write a test case showing the existing code gives incorrect behavior.
Then, go make the obvious fix.
Bill Pugh
13 Comments:
Thank you for your post, I look for such article along time, today i find it finally. this post give me lots of advise it is very useful for me.
Best bca college in noida
Top bca colleges in noida
Its like you learn my thoughts! You seem to understand a lot approximately this, like you
wrote the ebook in it or something.
ivanka trump hot pics
read this above post its very greatful for me thanks sharing this post ,great post.
site...
Zong always tried to offer incredibly affordable call and SMS packages to its subscribers. The company also offers unmatched social, 2G, 3G and 4G Zong internet packages for its users. Here, I am going to compile a complete list of Zong internet packages. You can check the list and pick out the most affordable internet package for you.
Zong customers can make unlimited voice and video calls on Whatsapp with Zong 4G. You can also chat, share data on Whatsapp with absolutely no charge.
Zong Monthly
WhatsApp Package. Zong bring something which gives the great value of their money. That's the reason they keep the price low for WhatsApp bundles so the user can enjoy more data volume. To subscribe to free Whatsapp, you simply need to dial *247# and start enjoying all Whatapp features.
Weekly packages, Monthly packages ...
Zong 4G is one of the most successful mobile data networks in Pakistan. Zong 4G internet packages are designed carefully in order to meet. Zong Internet Packages 2G/3G/4G/5G Hourly, Daily, Weekly & Monthly along with Activation code and price. Zong internet packages are Best.
Zong is an international cellular network. Zong won the auction of 3G and 4G. 4G Internet packages are yet to come. Zong will ensure its customer to give quality
Zong 4G is one of the most successful mobile data networks in Pakistan. Zong 4G internet packages are designed carefully in order
Look sleek and sophisticated with our Kurti collection this season! Shop online from basic, embroidered, digital or printed kurti.Look sleek and sophisticated with our Kurti collection this season! Shop online from basic, embroidered, digital or printed Lawn Printed Kurti Buy Women's Kurtis online in Pakistan at 7 Day Returns, and ... Pure Cotton stuff print and Embroidery Shirt / Kurti (New Design 2020). kurti.abric in printed,cambric,shiffon dyed & embroidered spring colors Short kurti in Purple, Green, Blue, White, Grey, range, Yellow, Peach,Black, Red, Brown, Pink, Buy Women's Kurtis online in Pakistan at, 7 Day Returns, and Cash on Delivery offers.
I have read your article and I gathered some new information through your article. Astroswmig is India's famous astrology prediction website.here you know your horoscope and kundali as per your date of birth and ask questions to the top astrologers of India regarding your problems.
Talk To Astrologer
Aaj ka Rashifal
Online Astrologer
Free kundli Prediction
Free-Astrology-Predictions
Thankful to you for sharing this key data! Need you will stick doing such an exercises you're doing. The Printhead Error on HP Officejet Pro 6830 happen when the ink system are damage and some cases in are leaking in cartridge. Contact our executives we help you to Fix the error.
I believe this will help your website become more organized because you have decided to set a part on this site for the inquiries regarding tax and as well as the helpful discussions. To be honest, this is one of the few sites that are doing this kind of strategy. write my assignment Also, I think that this will not only benefit your clients or the potential ones but you most especially because you will be able to see the questions easier.
This is a good idea for people who actually have some questions or inquiries about this topic. I am so excited to see the discussions that will be made on this thread regarding taxes. I have to say that this kind of topic should really be discussed thoroughly to people who assignment writing help finds it helpful so that there won't be no confusions anymore.
I trully appretiate your work and tips given by you is helpful to me. I will share this information with my family & friends. This is a great website, keep the positive reviews coming. This is a great inspiring .I am pretty much pleased with your good work. You assignment help online put really very helpful information. I am looking to reading your next post. !!!!
This post is very unique and informative for all. Impressive information you share in this. Keep it up and keep sharing.
eniac full form in computer
dvd full form
sit full form
pcc full form
iucn full form
full form of lcd
brics full form
tally erp full form
full form of ctbt
crpf full form
This comment has been removed by the author.
I appreciate the thorough analysis presented in this post. Coreball Game is such an addictive game, perfect for when you need a break from work.
Post a Comment
<< Home