• Kelly (unregistered)

    Wow

  • (cs)

    Man.  If only they had decided to put a Visible property at the base level for all server controls.  Life would be sweet then.  We could call the base class "Control", and it could have several properties, such as Visible, Enabled and even Width and Height!

    I'm going to write Microsoft now to let them know of my great idea!

  • (cs)

    <font size="2">I don't want to turn into AmmoQ, but aren't the semantics of a not-visible element different from those of a commented-out element? The former is still in the DOM's collections, no?</font>

  • J (unregistered)

    Well this person obviously knows that the Visible attribute exists, so this has got to be one of the most assanine things I have ever seen. Even if you needed to have more than just text to be dynamically hidden, why not just set the TD to runat server and show/hide that. This is just ridiculous. I really did say "what the f***" when I saw that. The Insanity is taking hold.

  • (cs)

    I would take a guess and say this is someone who still thinks he works in asp. Needs a wake-up call. A slap in the head would do nicely.

  • (cs) in reply to John Smallberries
    John Smallberries:
    <font size="2">I don't want to turn into AmmoQ, but aren't the semantics of a not-visible element different from those of a commented-out element? The former is still in the DOM's collections, no?</font>


    In addition, is an element with visible=false invisible on or non-existent on the client?  If it's the former, a commented element could create a state problem, since comment it would yield different behavior.  If the latter then, functionally, they behave the same.
  • lenny (unregistered) in reply to Smash
    Smash:
    I would take a guess and say this is someone who still thinks he works in asp. Needs a wake-up call. A slap in the head would do nicely.


    It would be a huge WTF in ASP also.  I vote for two slaps in the head, a chop to the kidneys,  and a swift knee to the groin area.

    Somebody needs to tell this guy that the CORRECT way of hiding text in an ASP.NET page is to put in in a
    and setting the div's display = 'none' in javascript.   Duh....


  • (cs)

    Not as bad as some ASP.NET stuff I have seen.  I place I used to work would build the entire page as a concatenate string in the code behind.  Really makes you say WTF and pound you head on a monitor when you see such abuse of OOP like this one. 

  • (cs) in reply to John Smallberries
    John Smallberries:
    <font size="2">I don't want to turn into AmmoQ, but aren't the semantics of a not-visible element different from those of a commented-out element? The former is still in the DOM's collections, no?</font>

    I stay far, far away from Microsoft technologies, but my guess here is that 'visible' attribute determines whether or not a particular thing is emitted into the block of HTML that goes back to the browser.  So, I suspect a comment is actually more 'visible' to the client than a !visible ASP.NET element.

    Perhaps the programmer had some good reason for wanting to see the thing being commented out in a comment.

  • J (unregistered) in reply to Omnifarious
    I stay far, far away from Microsoft technologies, but my guess here is that 'visible' attribute determines whether or not a particular thing is emitted into the block of HTML that goes back to the browser. So, I suspect a comment is actually more 'visible' to the client than a !visible ASP.NET element.

    That is correct. When Visible is set to false, the control is not rendered to the browser at all.

  • (cs) in reply to J
    Anonymous:
    That is correct. When Visible is set to false, the control is not rendered to the browser at all.

    I verified this. Visible = False is not the same as a CSS style such as display: none;

    This is well and truly a big, fat steaming WTF.
  • Fregas (unregistered)

    This IS amusing, but not necessarily a huge WTF assuming they had some reason during debugging where they wanted to see the commented out code by viewing the source.  But they shouldn't have kept this SHITE in production.  They are making the page fatter by sending out more HTML than is necessary.

  • (cs) in reply to Fregas
    Anonymous:
    This IS amusing, but not necessarily a huge WTF assuming they had some reason during debugging where they wanted to see the commented out code by viewing the source.  But they shouldn't have kept this SHITE in production.  They are making the page fatter by sending out more HTML than is necessary.


    It wouldn't be a WTF if there were not something called a debugger available for debugging.
  • (cs) in reply to Ytram
    Ytram:
    Man.  If only they had decided to put a Visible property at the base level for all server controls.  Life would be sweet then.  We could call the base class "Control", and it could have several properties, such as Visible, Enabled and even Width and Height!

    I'm going to write Microsoft now to let them know of my great idea!


    Man, if only the base post of this WTF mentioned the Visibly property being available for every control!
  • (cs) in reply to Fregas
    Anonymous:
    This IS amusing, but not necessarily a huge WTF assuming they had some reason during debugging where they wanted to see the commented out code by viewing the source.  But they shouldn't have kept this SHITE in production.  They are making the page fatter by sending out more HTML than is necessary.


    We can only take it at face value so you can't make that assumption.  If it causes one developer to raise an eyebrow and look at it for an extra second, without a real purpose (besides our entertainment), then it costs someone something.  I submit to you that it remains a WTF.
  • David (unregistered) in reply to wisew

    wisew:
    Not as bad as some ASP.NET stuff I have seen.  I place I used to work would build the entire page as a concatenate string in the code behind.  Really makes you say WTF and pound you head on a monitor when you see such abuse of OOP like this one. 

     

    [:$][:$]*Whistles innocently*

     

    In my defense I had to teach myself .asp programming from asp pages written by a guy who taught himself .asp programming from scratch in a department made up of 3 30+ years of experience guys programming FORTRAN and 1 guy around 4 years in the business who knew about as much about asp pages as I did.

  • (cs)
    I figured out what was wrong with this code...  He depends on the value of "true" being true!
    What if it was false?
    .....
    If quoteRequest.PreferenceCode <> "P" Then
    

    lblIStart4.Text = "<!--" lblIStart4.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT> lblIEnd4.Text = "-->" lblIEnd4.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>

    If quoteRequest.GuidelineException > GuidelineExceptions.Minor Then lblIStart5.Text = "<!--" lblIStart5.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>

    lblIEnd5.Text = <SPAN style="COLOR: #848284">"--&gt;"</SPAN>
    lblIEnd5.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 &lt;&gt; 0 )</FONT>
    

    End If

    End<FONT color=#000000> </FONT>If
    There, I think that's much better.  (Who wants to pat me on the back?)

  • (cs) in reply to iAmNotACantalope
    iAmNotACantalope:
    I figured out what was wrong with this code...  He depends on the value of "true" being true!
    What if it was false?
    .....
    If quoteRequest.PreferenceCode <> "P" Then
      lblIStart4.Text = "<!--"</SPAN>
      lblIStart4.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>
      lblIEnd4.Text = <SPAN style="COLOR: #848284">"-->"
      lblIEnd4.Visible = <font color="#0000ff">( 1 = 1 ) and ( 1 <> 0 )</font>
    

    If quoteRequest.GuidelineException > GuidelineExceptions.Minor Then lblIStart5.Text = "<!--" lblIStart5.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>

    lblIEnd5.Text = <SPAN style="COLOR: #848284">"-->"</span>
    lblIEnd5.Visible = <font color="#0000ff">( 1 = 1 ) and ( 1 &lt;&gt; 0 )</font>
    

    End If

    End<font color="#000000"> </font>If
    There, I think that's much better.  (Who wants to pat me on the back?)



    But what if it was really looking for true or false (instead of using magic numbers, which you have resorted to)

    Oh, and I think you may have misspelled cantaloupe.
  • (cs) in reply to Fregas

    Anonymous:
    This IS amusing, but not necessarily a huge WTF assuming they had some reason during debugging where they wanted to see the commented out code by viewing the source.  But they shouldn't have kept this SHITE in production.  They are making the page fatter by sending out more HTML than is necessary.

    The Visual Studio integrated debugger is great for that.  This is a WTF.

  • (cs) in reply to David
    Anonymous:
    In my defense I had to teach myself .asp programming from asp pages written by a guy who taught himself .asp programming from scratch in a department made up of 3 30+ years of experience guys programming FORTRAN and 1 guy around 4 years in the business who knew about as much about asp pages as I did.

    Your defense? Is this your code?!
  • (cs) in reply to Mike R
    Mike R:
    iAmNotACantalope:
    I figured out what was wrong with this code...  He depends on the value of "true" being true!
    What if it was false?
    .....
    If quoteRequest.PreferenceCode <> "P" Then
      lblIStart4.Text = "<!--"</SPAN>
      lblIStart4.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>
      lblIEnd4.Text = <SPAN style="COLOR: #848284">"-->"
      lblIEnd4.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>
    

    If quoteRequest.GuidelineException > GuidelineExceptions.Minor Then lblIStart5.Text = "<!--" lblIStart5.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 <> 0 )</FONT>

    lblIEnd5.Text = <SPAN style="COLOR: #848284">"-->"</SPAN>
    lblIEnd5.Visible = <FONT color=#0000ff>( 1 = 1 ) and ( 1 &lt;&gt; 0 )</FONT>
    

    End If

    End<FONT color=#000000> </FONT>If
    There, I think that's much better.  (Who wants to pat me on the back?)



    But what if it was really looking for true or false (instead of using magic numbers, which you have resorted to)

    Oh, and I think you may have misspelled cantaloupe.

     

     

    Ok, the joke was lost, as the whole point was trying to poke fun at magic numbers.  And to be pendantic, I didn't use magic numbers, I used magic formulas ;) 

  • (cs) in reply to iAmNotACantalope
    iAmNotACantalope:

    Ok, the joke was lost, as the whole point was trying to poke fun at magic numbers.  And to be pendantic, I didn't use magic numbers, I used magic formulas ;) 



    Mmmh, you're right. Actually, your magic formulas use magic numbers, so that's, like, double the magic!
  • (cs) in reply to iAmNotACantalope

    Yeah this is a pretty big WTF... I think the guy was trying to save view state. Thinking by commenting out the code with labels instead of using the .visible will decrease view state and thus increase response time... Not logical but a possiblity... Which would make this someone who has read/experinced basics of asp.net and very little on actual implemtation...

  • David (unregistered) in reply to John Smallberries

    John Smallberries:
    Anonymous:
    In my defense I had to teach myself .asp programming from asp pages written by a guy who taught himself .asp programming from scratch in a department made up of 3 30+ years of experience guys programming FORTRAN and 1 guy around 4 years in the business who knew about as much about asp pages as I did.

    Your defense? Is this your code?!

     

    No no no.  I was referring specifically to the comment someone made about concatenating all the HTML into one string in the code then writing that one string all at once. 

  • (cs)

    Wow...I've been lurking on this site for a few weeks now, but I just have to comment on this one.

    I'm staggered...I'm not an ASP or ASP.NET programmer in any way shape or form, but I'm CERTAIN there are MANY better ways of doing this.

  • (cs) in reply to David
    Anonymous:

    John Smallberries:
    Anonymous:
    In my defense I had to teach myself .asp programming from asp pages written by a guy who taught himself .asp programming from scratch in a department made up of 3 30+ years of experience guys programming FORTRAN and 1 guy around 4 years in the business who knew about as much about asp pages as I did.

    Your defense? Is this your code?!

     

    No no no.  I was referring specifically to the comment someone made about concatenating all the HTML into one string in the code then writing that one string all at once. 



    Good save.  You don't want Smallberries on your a$$.  He's a viper.
  • K (unregistered)

    The funniest thing is, he/she might get paid more than most of the developers nowadays... [:(]

  • (cs) in reply to Mung Kee

    Mung Kee:

    Good save.  You don't want Smallberries on your a$$.

    Yeah, smallberries on the ass sounds like a bad condition.

  • PaulaBean (unregistered) in reply to Mung Kee

    Brillant...

  • (cs) in reply to David
    Anonymous:

    John Smallberries:
    Anonymous:
    In my defense I had to teach myself .asp programming from asp pages written by a guy who taught himself .asp programming from scratch in a department made up of 3 30+ years of experience guys programming FORTRAN and 1 guy around 4 years in the business who knew about as much about asp pages as I did.

    Your defense? Is this your code?!

    No no no.  I was referring specifically to the comment someone made about concatenating all the HTML into one string in the code then writing that one string all at once. 


    *phew* that's good to hear.

    Actually, in classic ASP, building an HTML string is more performant than you might think.
    If most of the page's content is dynamic, building am HTML string then Response.Write'ing that is better. Interleaving server side tags with the static HTML is slow since the parser much switch contexts.

    That said, do not simply concatenate a string to build the HTML. That is the worst way to do it. I wrote a class that added strings to an array, then joined them at the end (a poor man's StringBuilder). It increased string concat performance 100x.

  • (cs) in reply to Mung Kee
    Mung Kee:

    Good save.  You don't want Smallberries on your a$$.  He's a viper.

    Oh, and your the essence of understanding and forgiveness? [;)]


  • (cs) in reply to John Smallberries
    John Smallberries:
    Mung Kee:

    Good save.  You don't want Smallberries on your a$$.  He's a viper.

    Oh, and your the essence of understanding and forgiveness? [;)]




    Just kidding but, in truth, we all have our moments.
  • (cs) in reply to John Smallberries
    John Smallberries:

    Actually, in classic ASP, building an HTML string is more performant than you might think.
    If most of the page's content is dynamic, building am HTML string then Response.Write'ing that is better. Interleaving server side tags with the static HTML is slow since the parser much switch contexts.


    If you have Response.Buffer off (default in IIS 4 ASP) the server actually sends the bits to the client at every context switch.

    This can help the browser render while receiving... creating the illusion of good performance... but if you have LOTS of tags like I do it gets silly.  Better to put Response.Buffer = False and have a few well-placed Response.Flush's.
  • (cs) in reply to Maurits
    Maurits:
    John Smallberries:

    Actually, in classic ASP, building an HTML string is more performant than you might think.
    If most of the page's content is dynamic, building am HTML string then Response.Write'ing that is better. Interleaving server side tags with the static HTML is slow since the parser much switch contexts.


    If you have Response.Buffer off (default in IIS 4 ASP) the server actually sends the bits to the client at every context switch.

    This can help the browser render while receiving... creating the illusion of good performance... but if you have LOTS of tags like I do it gets silly.  Better to put Response.Buffer = False and have a few well-placed Response.Flush's.


    Not just silly but maddening.  Eventually you will have "& _" burned into your cornea from overexposure.
  • (cs) in reply to John Smallberries

    John Smallberries:

    Actually, in classic ASP, building an HTML string is more performant than you might think.
    If most of the page's content is dynamic, building am HTML string then Response.Write'ing that is better. Interleaving server side tags with the static HTML is slow since the parser much switch contexts.

    The parser "switching contexts" is a trival time drain.  Basically if you write

    <%   Response.Write ("STUFF")   %>
    stuffstuffstuffstuff
    <%   Response.Write ("STUFF")   %>

    The parser just renders that as:

     Response.Write ("STUFF") 
     Response.Write ("stuffstuffstuffstuff")
     Response.Write ("STUFF") 

    The actual time difference comes from the fact the (usually) concatenating two strings and the writing one long string is faster that writing two short strings.  Of course, if the strings get very long, concatenation takes longer, to the point where two writes are faster. 

  • (cs) in reply to iAmNotACantalope
    iAmNotACantalope:


      <font size="2">lblIEnd4.Visible = ( 1 = 1 ) And ( 1 <> 0 )</font>


    This can be made more efficient by writing it like this:

      <font size="2">lblIEnd4.Visible = ( 1 = 1 ) AndAlso ( 1 <> 0 )</font>

    Then it will short-circuit the logic if 1 really equals 1. In fact, since there is no performance penalty involved, you might as well append all your conditional statements with basic checks for race logical conditions (like checking that True doesn't equal False):

    <font size="2">If (checkFor = True AndAlso 1 = 1 AndAlso 1 <> 0 AndAlso Black <> White...) Then</font>

  • Daniel T (unregistered)

    It's also a WTF because it's mixing logic with layout in a real bad way.  HTML comments should NOT appear in a code-behind file.  What if someone happens to modify the template by adding this:

    <asp:Label id="lblIStart5" visible="False" runat="server"></asp:Label>
    <td valign="top" width="100%">
    additional fee required, check
    <a href="/help/guidelines.aspx#additionalfees">guidelines</a>
    for more information
    <font size="4"><!-- blah blah blah --></font>
    </td>
    <asp:Label id="lblIEnd5" visible="False" runat="server"></asp:Label>
    Bingo - nested comment!

    --Daniel T

    p.s. Like a lot of WTF's, this is pretty darn creative :-)

  • (cs)

    I've seen this antipattern before; it was an early web-application built upon a poorly made template engine that could only replace place holders with actual values, but had no conditional construct.

  • Arachnid (unregistered) in reply to azaris
    azaris:
    iAmNotACantalope:


      <font size="2">lblIEnd4.Visible = ( 1 = 1 ) And ( 1 <> 0 )</font>


    This can be made more efficient by writing it like this:

      <font size="2">lblIEnd4.Visible = ( 1 = 1 ) AndAlso ( 1 <> 0 )</font>

    Then it will short-circuit the logic if 1 really equals 1. In fact, since there is no performance penalty involved, you might as well append all your conditional statements with basic checks for race logical conditions (like checking that True doesn't equal False):

    <font size="2">If (checkFor = True AndAlso 1 = 1 AndAlso 1 <> 0 AndAlso Black <> White...) Then</font>



    Tell me VB.net doesn't have 'AndAlso' just to provide short circuiting. Why couldn't they change that behaviour when they were changing everything else in the transition to VB.net? Every other language short-circuits by default.

    This is worthy of a WTF all of its own.
  • (cs)

    Hmm... Those programmers that write "WTF-code" are really innovative...

  • (cs) in reply to md2perpe
    md2perpe:
    Hmm... Those programmers that write "WTF-code" are really innovative...


    As someone once said: "It's pointless to try making something idiot-proof, because nature keeps making better idiots".
  • (cs) in reply to Arachnid
    Anonymous:

    Tell me VB.net doesn't have 'AndAlso' just to provide short circuiting


    It does.

    Anonymous:

    Why couldn't they change that behaviour when they were changing everything else in the transition to VB.net


    They tried in pre-release versions of VB.Net 1.0 -- VB developers rose up in unison and demanded they put it back to the way they were used to.

    Anonymous:

    Every other language short-circuits by default.


    Yup.

    Anonymous:

    This is worthy of a WTF all of its own.


    Yup.
  • (cs) in reply to ammoQ
    ammoQ:
    I've seen this antipattern before; it was an early web-application built upon a poorly made template engine that could only replace place holders with actual values, but had no conditional construct.


    This can't be all ammoQ - I've enjoyed the banter the past couple of days.  I want more, more, more!

  • (cs) in reply to bugsRus
    bugsRus:
    ammoQ:
    I've seen this antipattern before; it was an early web-application built upon a poorly made template engine that could only replace place holders with actual values, but had no conditional construct.


    This can't be all ammoQ - I've enjoyed the banter the past couple of days.  I want more, more, more!


    I'm too busy working on new oxymorons, like tightly seperated
  • (cs) in reply to ammoQ

    twichs

    This goes right up there with that ASP prasing system we saw a few months back, expect this one isn't justifyable.

  • (cs) in reply to John Smallberries
    John Smallberries:
    Anonymous:
    That is correct. When Visible is set to false, the control is not rendered to the browser at all.

    I verified this. Visible = False is not the same as a CSS style such as display: none;

    This is well and truly a big, fat steaming WTF.


    Not to be funny or anything but to settle this once and for all visable=false will still include the control on the page (as in a hidden asp textbox) whereas enabled=false will actually stop the control being included in the page.

    Oh and by the way W.T.F mate? This code is Brillant!!!!
  • Oha Ooh (unregistered) in reply to ray

    ray:
    Not to be funny or anything but to settle this once and for all visable=false will still include the control on the page (as in a hidden asp textbox) whereas enabled=false will actually stop the control being included in the page.

    It's the other way round: enabled=false will still include the control on the page whereas visible=false will not render the control on the page any more.

  • (cs) in reply to Arachnid
    Anonymous:

    Tell me VB.net doesn't have 'AndAlso' just to provide short circuiting. Why couldn't they change that behaviour when they were changing everything else in the transition to VB.net? Every other language short-circuits by default.

    This is worthy of a WTF all of its own.


    Many companies ported their VB6 code to VB.NET. Do you think it's more of a WTF to add a short-circuiting operator or to silently break existing code?

  • (cs) in reply to rikkus
    rikkus:
    Anonymous:

    Tell me VB.net doesn't have 'AndAlso' just to provide short circuiting. Why couldn't they change that behaviour when they were changing everything else in the transition to VB.net? Every other language short-circuits by default.

    This is worthy of a WTF all of its own.


    Many companies ported their VB6 code to VB.NET. Do you think it's more of a WTF to add a short-circuiting operator or to silently break existing code?



    Existing code had to be reworked anyway; I don't know vb.net but in C#, you need short-curcuiting all the day for cases like that:

    if (something != null && something.WTF) { ... }

    Since vb.net has similar semantics and works on the same class libs, I guess you need it in vb.net just as often.
  • (cs) in reply to ammoQ

    I think I actually got a slight bit dizzy when reading this WTF.

Leave a comment on “All Commented Out”

Log In or post as a guest

Replying to comment #:

« Return to Article