Cork24 wrote: » Some really funny comments
Cork24 wrote: » Thats where Commments come into play, every program i do, i have about 3 lines of Comment over every Method/Function telling what its doing and where its pointing to if i was using Pointers or Abstract Coding in Java.
//Not really sure why this isn't working properly — it's bizarre
Feathers wrote: » Trying to put tests around some legacy code at the moment. Have gotten a few if "true then true"s alright, as well as some comments along the lines of://Not really sure why this isn't working properly — it's bizarre How helpful! :rolleyes:
try { byte[] result = ... several lines of messy network code ...; return result; } catch(Exception e) { } return new byte[1];
lines = mrg_output.split("\n")
lines = mrg_output.splitlines()
string.endswith('bla') or string.endswith('bla\r')
zynaps wrote: » oh no you didn't leave an empty catch block
Feathers wrote: » Surely you mean why it's doing something, as opposed to what it's doing? I hope that any developer working on my project, past or present, should be able to look at a method & read what is going on.
ciaranmac wrote: » You'd hope that would be the case. Where comments sometimes come in useful is when the code doesn't do what the original developer expected it to. The comments say what it's meant to do, a tight reading of the code tells you it does something different, and resolving the problem is easier than it would be without the comment.
Earthhorse wrote: » Or what if they wrote the comment wrong too? What if the comment says "This method returns all clients" whereas the code returns all current clients? Which one is correct?
conor.hogan.2 wrote: » Whatever is in the spec (whatever or wherever the spec is).
Earthhorse wrote: » Of course. The point is that the comment can be wrong too; in fact, it might be more likely to be wrong than the code because there won't be any tests run against it.
GreeBo wrote: » If the code is wrong then the test is also wrong by definition, otherwise the test would fail. Id rather take the risk of having the odd wrong comment than no comments.
GreeBo wrote: » If the code is wrong then the test is also wrong by definition, otherwise the test would fail.
void obj::send(std::string str) { if(!isStarted()) { send(str); } else { mem->passString(str); } }
<form method="post" action="<?php the_permalink(); ?>"> <table><tbody><tr> <?php $current_user = wp_get_current_user(); $user_video_pref = get_user_meta($current_user->ID, 'namespace_video_size_pref', true); $arr = array("960x540","720x406","320x180", "Auto"); echo "\n"; foreach ($arr as $value) { echo "\n<td id='td-".$value; echo "' onMouseOver=\"this.style.backgroundColor='#f9f9f9'\"; "; echo " onMouseOut=\"this.style.backgroundColor='#DCDCDC'; if (document.getElementById('namespace_video_size_pref".$value."').checked) {document.getElementById('td-960x540').style.backgroundColor='#DCDCDC';document.getElementById('td-720x406').style.backgroundColor='#DCDCDC';document.getElementById('td-320x180').style.backgroundColor='#DCDCDC';document.getElementById('td-Auto').style.backgroundColor='#DCDCDC';this.style.backgroundColor='#f9f9f9'; }\" "; echo " onClick=\"this.style.backgroundColor='#DCDCDC'; if (document.getElementById('namespace_video_size_pref".$value."').checked) {document.getElementById('td-960x540').style.backgroundColor='#DCDCDC';document.getElementById('td-720x406').style.backgroundColor='#DCDCDC';document.getElementById('td-320x180').style.backgroundColor='#DCDCDC';document.getElementById('td-Auto').style.backgroundColor='#DCDCDC';this.style.backgroundColor='#f9f9f9'; }\" "; echo " style='padding:0; border:0;"; if ($value==$user_video_pref) echo " background-color:#f9f9f9; border: 2px solid #444' class='namespace-selected-video-option"; echo "'>\n<label for='namespace_video_size_pref".$value."'>"; if ($value=="960x540") echo "<h3 style='margin:0 0 0 45px;'>Large</h3>"; if ($value=="720x406") echo "<h3 style='margin:0 0 0 45px;'>Medium</h3>"; if ($value=="320x180") echo "<h3 style='margin:0 0 0 45px;'>Small</h3>"; if ($value=="Auto") echo "<h3 style='margin:0 0 0 45px;'>Auto</h3>"; echo '<img src="http://images.namespace.com/'; echo $value.'.gif" alt="Choose image size" style="border:1px solid #585F6B;" /> <br/>'; echo '<input type="radio" style="padding:10px; margin: 5px 0 0 70px " name="namespace_video_size_pref" id="namespace_video_size_pref'.$value.'" value="'.$value.'"'; if ($value==$user_video_pref) echo " checked "; echo "><br /> <br /></label>"; echo "\n</td>\n"; } ?> </tr></tbody></table> <input name="updateuser" type="submit" id="updateuser" class="submit button" value="Update" /> <input name="action" type="hidden" id="action" value="update-user" /> </form>
GreeBo wrote: » ^ ouch my eyes! Im surprised the whole thing isnt wrapped in a string and eval'd. Thats like inception or something.
c_man wrote: » void obj::[B]send[/B](std::string str) { if(!isStarted()) { [B]send(str);[/B] } else { mem->passString(str); } }
void obj::[B]send[/B](std::string str) { if(!isStarted()) { [B]send(str);[/B] } else { mem->passString(str); } }
zynaps wrote: » Am I missing something that makes this not an infinite recursion/stackdeath if isStarted() doesn't return true (quickly)?
Triangle wrote: » If X = Y then Y = X ....... The sad thing is people paid for this logic.
/* ** float q_rsqrt( float number ) */ float Q_rsqrt( float number ) { long i; float x2, y; const float threehalfs = 1.5F; x2 = number * 0.5F; y = number; i = * ( long * ) &y; // evil floating point bit level hacking i = 0x5f3759df - ( i >> 1 ); // what the ****? y = * ( float * ) &i; y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed return y; }