Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi all! We have been experiencing an issue on site where threads have been missing the latest postings. The platform host Vanilla are working on this issue. A workaround that has been used by some is to navigate back from 1 to 10+ pages to re-sync the thread and this will then show the latest posts. Thanks, Mike.
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

Coding Horror

13468922

Comments

  • Registered Users, Registered Users 2 Posts: 1,529 ✭✭✭zynaps


    Sparks wrote: »
    BASIC?

    #define ALLBETS 0 /* :D */
    Most (structured) Basics I encountered were awesome... at least, from the perspective of someone coming directly from C64 Basic, which was horrendous... Only the first two letters of variable names were considered, line numbers were mandatory and there was no auto-renumber function, so you had to space the numbers in increments that were proportional to your uncertainty about how much various sections of code would need refactoring or expansion later...

    And even that was probably a big improvement to writing in assembly on a cassette tape based system with the most rudimentary editor (or "monitor").

    The most arbitrary disappointing experiences were when you typed in a "Basic" program from a magazine listing, which was actually just a small for loop which would read bytes from the data section and poke them into memory. The bytes were machine code opcodes, so you might have to type in 10 or 20 lines of these numbers, and you just knew it wasn't going to work, because a single error would almost certainly ruin the whole thing.
    The ~30% of the time that you managed to do it without making an error or giving up halfway through, the program would be rubbish anyway and the only enjoyment would be a kind of "I escaped from prison with a toothpick and it only took 35 years" grim satisfaction... :D


  • Registered Users, Registered Users 2 Posts: 7,518 ✭✭✭matrim


    Was looking through some of our old libraries (which are still used for some core stuff) today and behind the scenes had what was basically a factory called farm, which created objects called moo_cow, with no comments or explaination of what either did.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,473 Mod ✭✭✭✭Capt'n Midnight


    zynaps wrote: »
    Most (structured) Basics I encountered were awesome...
    Know someone who had to program in BASIC , but space was limited. So no REM statements, liberal use of : to put as many statements on a single line as possible to save space - printouts would have been a wall of text.


  • Registered Users, Registered Users 2 Posts: 27,253 ✭✭✭✭GreeBo


    a class called
    NumericConstants.java
    containg over 100 definitions similar to
    /*
    * Constant for one hundred
    */
    public static final int ONE_HUNDRED = 100;
    /*
    * Constant for one hundred twelve
    */
    public static final int ONE_HUNDRED_TWELVE = 112;

    Thank heavens for the comments or it would have been so confusing.

    /edit now that I think about it, Im not even sure they were final...


  • Closed Accounts Posts: 503 ✭✭✭Boards.ie: Neil


    another beauty courtesy of vbulletin...

    ever wonder how those stars to the <<< left are calculated?

    [php]
    for ($x = $rank; $x--; $x > 0)
    {
    if (empty($rank))
    {
    $userrank .= "<img src=\"http://b-static.net/vbulletin/$rank\" alt=\"\" border=\"\" />";
    }
    else
    {
    $userrank .= 'http://b-static.net/vbulletin/' . $rank;
    }
    }
    [/php]

    and where is this string of html used you say? oh yes it's inserted into the database...


  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭PrzemoF


    COYW wrote: »
    [..] I was told not to comment my code, as it was a "waste of time". Apparently, that is classic Agile!

    A good code doesn't need comments; a bad code doesn't need comments either - it needs to be fixed! ;)


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    PrzemoF wrote: »
    A good code doesn't need comments; a bad code doesn't need comments either - it needs to be fixed! ;)

    Hm. Even in jest, that brings my need to strangle to the fore...


  • Registered Users, Registered Users 2 Posts: 2,029 ✭✭✭Colonel Panic


    I don't know how I feel about comments. I mostly use C and C++ and think of header files as de facto documentation of code, albeit documentation that relies heavily on the actual quality of the code itself, I must admit.

    I find that Doxygen comments in headers (or worse still, some custom nonsense with lots of ascii formatting) just ends up being noise. Especially when it's superfluous stuff telling me what the function definition already tells me in less text.

    Where I like to see comments is in the actual implementations where sometimes the motivation of the developer might not be clear. Be it some sort of optimisation, an apology to other developers or perhaps a reference to where that piece of code is used.

    Where I do use comments in headers is to basically say a little about the basic usage of the code defined in the file, any potential side effects, references to dependencies, comments about compiler flags, hacks or future work etc.

    An example I found a couple of days ago is in RIM's Gameplay framework for cross platform game dev. IMO, it's a pretty solid framework. Well written with APIs that make sense, but look at all the noise in this file...

    https://github.com/blackberry/GamePlay/blob/master/gameplay/src/Game.h

    If you took out the comments, the whole thing would be more compact and make just as much sense! Hell, some of the functions have params that need explaining in the comments but they aren't mentioned! RenderOnce takes a void pointer param called cookie. What is that for? Better look at the implementation...

    Now, I recognise that this is more for the benefit of tools that generate documentation, but the cost is pretty high imo!


  • Registered Users, Registered Users 2 Posts: 40,038 ✭✭✭✭Sparks


    It's a matter of degree; if I saw, say:
    int i; // Declare variable i
    i = 0; //Define variable i
    i++; //Increment variable i
    
    Then that'd set off some alarms and I'd wind up reading that person's code very carefully for mistakes.

    If, on the other hand, I see ten lines of dense code without a single comment giving an overview, I'm going to refuse to pass it through code review. It might be obvious to the coder today what they meant; in a month's time, they may not remember; when some other poor schmuck has to debug it in two years time, the original coder may not even be with the company anymore. One line of comment saying "here we do X" is not onerous, and it's the easiest line to write.

    edit: Here's a quick test for you; go back to code you wrote ten years ago (you still have your code from college exercises, right? No? You don't keep a private archive of old code you wrote? So... how do you tell if you're improving or getting worse without a baseline?). Now, see if you can read it in one pass and understand what it was doing. That's a pretty object lesson right there.

    And if someone does something for optimisation reasons and doesn't have comments in the code stating what they're doing, and what they're assuming when doing it, then someone's getting the engineering version of a kick in the fork for being the person that keeps someone else working till 0200 on a weekend instead of sleeping/eating/playing with their kids.

    Comments are the bit in the code that says "not only can I code, but I'm professional enough to realise that I work with other peons". Not commenting appropriately is just downright obnoxious...


  • Registered Users, Registered Users 2 Posts: 1,109 ✭✭✭Skrynesaver


    Sparks wrote: »
    It's a matter of degree; if I saw, say:

    If, on the other hand, I see ten lines of dense code without a single comment giving an overview, I'm going to refuse to pass it through code review. It might be obvious to the coder today what they meant; in a month's time, they may not remember; when some other poor schmuck has to debug it in two years time, the original coder may not even be with the company anymore. One line of comment saying "here we do X" is not onerous, and it's the easiest line to write.
    ...
    Not commenting appropriately is just downright obnoxious...

    +Infinity squared, your code could be present in the code base of the company for years and the maintainer of your code may be under pressure to resolve an issue that your code touches, clear explanation of what you think your code is doing is essential for maintainability.


  • Advertisement
  • Closed Accounts Posts: 2,930 ✭✭✭COYW


    PrzemoF wrote: »
    A good code doesn't need comments; a bad code doesn't need comments either - it needs to be fixed! ;)

    I presume this is a joke, so I will. :D


  • Closed Accounts Posts: 2,663 ✭✭✭Cork24


    PrzemoF wrote: »
    A good code doesn't need comments; a bad code doesn't need comments either - it needs to be fixed! ;)


    Do you work as a Developer ?

    Maybe you worked with Mircosoft for the Vista OS !!! yeah that could be it,

    All Code needs to be Commented on, What if i Wrote about 500 lines of Code in C, and 4 years later some one comes in to update some of the code, how is he meant to know what section of Code does what ?

    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.


  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭PrzemoF


    Cork24 wrote: »
    Do you work as a Developer ?

    Maybe you worked with Mircosoft for the Vista OS !!! yeah that could be it,

    All Code needs to be Commented on, What if i Wrote about 500 lines of Code in C, and 4 years later some one comes in to update some of the code, how is he meant to know what section of Code does what ?

    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.

    I do not, however some of my patches landed in the linux kernel (check my boards public profile and then search for commits signed with the same server name as my home page if you want to check their quality). I treat suggestion that I worked for MS as an insult ;)

    I prefer good procedure/function/variable names then something like (commented!):
    int lo; /* this is main counter*/

    Anyway, my post about good code/bad code was a JOKE! :D

    Some really funny comments


  • Registered Users, Registered Users 2 Posts: 7,157 ✭✭✭srsly78


    I got some good ones from a makefile:

    ## What is truth?
    ! := :
    !no := :
    yes := :


  • Registered Users, Registered Users 2 Posts: 9,559 ✭✭✭DublinWriter


    Pseudo-code:

    function is_pc_switched_on (boolean)

    return true;


  • Registered Users, Registered Users 2 Posts: 2,151 ✭✭✭dazberry


            Try
                m_bIndexing = configReader.GetValue("Indexing", GetType(Boolean))
            Catch ex As Exception
                m_bIndexing = True
            End Try
    
            If Not m_bIndexing Then
                mnuSeparator.Visible = False
                mnuSearch.Visible = False
            End If
    

    I don't know which annoys me more:
    • the fact that it's in vb.net
    • the fact that m_bIndexing is declared as a field in the form class and used only in one place (as shown)
    • the fact that the configReader.GetValue() pattern is repeated f**king everywhere in the project, including for the "Index" value again...
    • the fact that m_bIndexing is assigned true when declared, so the assignment in the exception handler is pointless
    • the If Not m_bIndexing .... = False
    • the fact that all the code is like this... muck
    • the fact that when this was being written, I was writing enterprise level code in a language that no one uses anymore so this is what I'm resigned to
    • the fact that my career has ended up scraping the seedy underbelly of the irish software industry

    D.


  • Closed Accounts Posts: 3,298 ✭✭✭Duggys Housemate


    dazberry wrote: »
            Try
                m_bIndexing = configReader.GetValue(&#34;Indexing&#34;, GetType(Boolean))
            Catch ex As Exception
                m_bIndexing = True
            End Try
    
            If Not m_bIndexing Then
                mnuSeparator.Visible = False
                mnuSearch.Visible = False
            End If
    

    I don't know which annoys me more:
    • the fact that it's in vb.net
    • the fact that m_bIndexing is declared as a field in the form class and used only in one place (as shown)
    • the fact that the configReader.GetValue() pattern is repeated f**king everywhere in the project, including for the "Index" value again...
    • the fact that m_bIndexing is assigned true when declared, so the assignment in the exception handler is pointless
    • the If Not m_bIndexing .... = False
    • the fact that all the code is like this... muck
    • the fact that when this was being written, I was writing enterprise level code in a language that no one uses anymore so this is what I'm resigned to
    • the fact that my career has ended up scraping the seedy underbelly of the irish software industry

    D.

    Surely he's correct to not assume that m_bindexing = true all the time.


  • Moderators, Recreation & Hobbies Moderators, Science, Health & Environment Moderators, Technology & Internet Moderators Posts: 92,473 Mod ✭✭✭✭Capt'n Midnight




  • Registered Users, Registered Users 2 Posts: 2,151 ✭✭✭dazberry


    Surely he's correct to not assume that m_bindexing = true all the time.

    I appreciate what you're getting at and why but in this case no it's not needed.

    And after that I had to try trace a partial stack trace from a log file where the methods names were obfuscated, and for that product the obfuscation maps were never saved by the build system - that's what I get for moaning :)

    D.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭PrzemoF




  • Closed Accounts Posts: 503 ✭✭✭Boards.ie: Neil


    So I've just come across another horror.

    [php]
    $editorid = construct_edit_toolbar($pagetext, 0, $foruminfo, iif($foruminfo, 1, 0), 1);
    [/php]

    the iif is NOT a typo, and $foruminfo will ALWAYS be either a 1 or 0.

    below is the code for iif (regulars here will remember Boards.ie: Paddy posting it before).

    [php]
    /**
    * Essentially a wrapper for the ternary operator.
    *
    * @deprecated Deprecated as of 3.5. Use the ternary operator.
    *
    * @param string Expression to be evaluated
    * @param mixed Return this if the expression evaluates to true
    * @param mixed Return this if the expression evaluates to false
    *
    * @return mixed Either the second or third parameter of this function
    */
    function iif($expression, $returntrue, $returnfalse = '')
    {
    return ($expression ? $returntrue : $returnfalse);
    }
    [/php]


  • Registered Users, Registered Users 2 Posts: 2,029 ✭✭✭Colonel Panic


    I see that so often, there should be a design (anti)pattern named in it's honour.


  • Closed Accounts Posts: 5 ciarank1


    i have only been doing java for a year or so now, but my god what i hate is INFINITE LOOPS... they are just terrible, but, one day i learned how to properly code an infinite 'for' loop, so i know how to fix them now, but not other loops :/


  • Registered Users, Registered Users 2 Posts: 1,082 ✭✭✭Feathers


    Cork24 wrote: »

    Some of these are brilliant :D
    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.

    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. (just programming in Java mainly at the minute).

    If the method is too big to follow, I'd rather break constituent parts into their own private methods (that can then be reused) rather than putting in a lot of comments.

    As in, the developer shouldn't get lost in the code & need comments to find their way. I'd use comments mostly for stuff like, if I was deprecating a method — why & what has replaced it; this is something that you can't find out just from reading the code underneath.

    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 &#8212; it's bizarre
    

    How helpful! :rolleyes:


  • Registered Users, Registered Users 2 Posts: 1,529 ✭✭✭zynaps


    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 &#8212; it's bizarre
    

    How helpful! :rolleyes:
    Well, it's at least helpful as a hint that you should write those unit tests to investigate the issue and figure out what the correct behaviour should be and why it's behaving differently now :)

    And my favourite pet peeve, having been bitten a few times (once by my own doing, more recently a colleague - both of us should know better):
    try {
      byte[] result = ... several lines of messy network code ...;
      return result;
    } catch(Exception e) {
    }
    return new byte[1];
    
    I was like "okay, it must be doing something because it's returning an actual array rather than null and not throwing any exceptions or printing an error... but why is the array only 1 element long, rather than at least several hundred bytes?" then 10 minutes later "....oh no you didn't leave an empty catch block and return a useless arbitrarily 1-byte-long array? ...KHAAAAAN!!!" :pac:


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 7,498 ✭✭✭BrokenArrows


    Was making a few small changes to some code today. I was shocked to see a very large amount of if/else conditions in the following format.

    If x == y
    // Do nothing
    Else
    // Do stuff

    The "// Do nothing" comment was actually in the code
    Needless to say I changed them all.

    Funnily enough the person who wrote the code is now the director of development.


  • Registered Users, Registered Users 2 Posts: 4,772 ✭✭✭cython


    Just came across this python doozy today that has wasted some of my time already. I found myself extending a script that we use for branch management, and needed to add some special case handling for specific files. All well and good you would think. Except that because someone had used
    lines = mrg_output.split("\n")
    
    instead of the platform-independent
    lines = mrg_output.splitlines()
    
    and I was running on Windows, the subsequent test I wanted to do using an endswith() failed because there was still a bloody '\r' in the returned string :mad::mad::mad: Surely it's better to do this, than to assume someone (i.e. me) will check
    string.endswith('bla') or string.endswith('bla\r')
    


  • Registered Users, Registered Users 2 Posts: 2,021 ✭✭✭ChRoMe


    zynaps wrote: »
    oh no you didn't leave an empty catch block

    People have died for less!


  • Closed Accounts Posts: 2,930 ✭✭✭COYW


    zynaps wrote: »
    oh no you didn't leave an empty catch block

    Love it! I've seen them before with the comments "I'll fill these in later".

    On commenting, I came across a method a few weeks ago that had a substring call in it which removed the last 2 characters in a string parameter with the comment "do not remove this line, it won't work".


  • Registered Users, Registered Users 2 Posts: 495 ✭✭ciaranmac


    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.

    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.


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 1,082 ✭✭✭Feathers


    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.

    So the person who added the comment knows it does something different to intended - why not refactor the code (e.g. renaming the method to what it actually does) rather than commenting it?


  • Registered Users, Registered Users 2 Posts: 14,714 ✭✭✭✭Earthhorse


    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?


  • Registered Users, Registered Users 2 Posts: 5,246 ✭✭✭conor.hogan.2


    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?

    Whatever is in the spec (whatever or wherever the spec is).


  • Registered Users, Registered Users 2 Posts: 14,714 ✭✭✭✭Earthhorse


    Whatever is in the spec (whatever or wherever the spec is).
    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.


  • Registered Users, Registered Users 2 Posts: 27,253 ✭✭✭✭GreeBo


    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.

    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.


  • Registered Users, Registered Users 2 Posts: 1,082 ✭✭✭Feathers


    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.

    It depends on what we mean by wrong — that it doesn't match the spec (so it's a bug), or that it does match the spec but the spec doesn't cover a case needed by business requirements — the current tests might but right, but incomplete.

    Either way, I'd say that as a general rule, comments shouldn't be able to be wrong — if so, you're commenting the type of thing that could instead by held in a variable or method name.


  • Registered Users, Registered Users 2 Posts: 1,529 ✭✭✭zynaps


    GreeBo wrote: »
    If the code is wrong then the test is also wrong by definition, otherwise the test would fail.
    True, but one common source of "buggy comments" is when the behaviour of other code changes for some valid reason, and a once-accurate comment becomes outdated and misleading. There will be no warning when this happens, because comments are freeform and not validated in any way... but as you point out, the tests should fail (assuming they are properly specified), quickly flagging the need to update the tests to reflect a new reality - which might reveal bugs in the new code, and so forth.

    Plus, since you have to specify your tests in a systematic and unambiguous way (code!), they are of course a better descriptor of expected behaviour than comments. That's not to say that I don't use comments to explain parts of the code that may look unnecessary or confusing that I haven't yet or couldn't refactor!


  • Registered Users, Registered Users 2 Posts: 14,714 ✭✭✭✭Earthhorse


    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.
    Ah here now, who said anything about "no comments"? Not I.

    All I'm saying is that it's fallacious to think that there where the comment and the code disagree the comment is more likely to be correct because it's "easier" to convey your intent in English.


  • Registered Users, Registered Users 2 Posts: 5,015 ✭✭✭Ludo


    Ah lads...this is the coding horror thread..there has been a big discussion about the merits (or lack thereof) of comments here already recently...
    http://www.boards.ie/vbulletin/showthread.php?t=2056835525


  • Closed Accounts Posts: 4,436 ✭✭✭c_man


    Came across one that slipped under the radar in a dusty part of the code base. Essentially this

    void obj::send(std::string str)
    {
       if(!isStarted())
       {
          send(str);
       }
       else
       {
           mem->passString(str);
       }
    }
    

    :(


  • Advertisement
  • Registered Users, Registered Users 2 Posts: 16,413 ✭✭✭✭Trojan


    This... works.
    <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 />&nbsp; <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>
    


  • Registered Users, Registered Users 2 Posts: 27,253 ✭✭✭✭GreeBo


    ^ ouch my eyes!

    Im surprised the whole thing isnt wrapped in a string and eval'd.
    Thats like inception or something.


  • Registered Users, Registered Users 2 Posts: 16,413 ✭✭✭✭Trojan


    GreeBo wrote: »
    ^ ouch my eyes!

    Im surprised the whole thing isnt wrapped in a string and eval'd.
    Thats like inception or something.

    Worse, I wrote it.


  • Registered Users, Registered Users 2 Posts: 1,529 ✭✭✭zynaps


    c_man wrote: »
    void obj::[B]send[/B](std::string str)
    {
       if(!isStarted())
       {
          [B]send(str);[/B]
       }
       else
       {
           mem->passString(str);
       }
    }
    

    :(
    Am I missing something that makes this not an infinite recursion/stackdeath if isStarted() doesn't return true (quickly)?


  • Closed Accounts Posts: 4,436 ✭✭✭c_man


    zynaps wrote: »
    Am I missing something that makes this not an infinite recursion/stackdeath if isStarted() doesn't return true (quickly)?

    Nope, you're right it was a potential infinite loop. Luckily for us up til now it always was bloody 'started' :P


  • Registered Users, Registered Users 2 Posts: 960 ✭✭✭Triangle


    If X = Y then Y = X
    .......

    The sad thing is people paid for this logic.


  • Registered Users, Registered Users 2 Posts: 1,931 ✭✭✭PrzemoF


    Triangle wrote: »
    If X = Y then Y = X
    .......

    The sad thing is people paid for this logic.

    I can't believe that a sane programmer would do it deliberately. Maybe that's a "pay-by-line-of-code" case? I heard a story about a drafters splitting lines in autocad, because they were paid by the number of entities on the drawing...


  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,104 Mod ✭✭✭✭Tar.Aldarion


    Haha love the comments in the source code
    http://www.reddit.com/r/programming/comments/1bnezw/jedi_outcastjedi_academy_source_code_released/

    And of course this beauty:
    /*
    ** 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;
    }
    


  • Registered Users, Registered Users 2 Posts: 2,029 ✭✭✭Colonel Panic


    Do you know the history of that piece of code? It's an incredibly fast square root approximation i the Quake 3 engine. I wouldn't call it a coding horror!!!

    http://en.wikipedia.org/wiki/Fast_inverse_square_root


  • Advertisement
  • Moderators, Science, Health & Environment Moderators, Social & Fun Moderators, Society & Culture Moderators Posts: 60,104 Mod ✭✭✭✭Tar.Aldarion


    I do know, I was just saying I liked that I saw it used (the games are on the quake engine)


Advertisement