Comment On All Commented Out

One of the many things that ASP.NET has made incredibly easy is dynamically showing/hiding text. You just put the text in a Label control and set the Visibility to false. I suppose you could do that with a Literal. Or a PlaceHolder. Or just about any of the System.Web.UI.HtmlControls. But if reeeaaally wanted to get creative, like Gavin's predecessor, you could place two labels around the block to turn it into one big HTML comment ... [expand full text]
« PrevPage 1 | Page 2Next »

Re: All Commented Out

2005-09-01 14:19 • by Kelly
Wow

Re: All Commented Out

2005-09-01 14:21 • by 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!

Re: All Commented Out

2005-09-01 14:25 • by John Smallberries
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?


Re: All Commented Out

2005-09-01 14:25 • by J
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.

Re: All Commented Out

2005-09-01 14:30 • by 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.

Re: All Commented Out

2005-09-01 14:36 • by Mung Kee
42680 in reply to 42676
John Smallberries:
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?





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.

Re: All Commented Out

2005-09-01 14:38 • by lenny
42681 in reply to 42678
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....





Re: All Commented Out

2005-09-01 14:42 • by 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. 

Re: All Commented Out

2005-09-01 14:43 • by Omnifarious
42683 in reply to 42676
John Smallberries:
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?



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.


Re: All Commented Out

2005-09-01 14:47 • by J
42684 in reply to 42683
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.

Re: All Commented Out

2005-09-01 15:03 • by John Smallberries
42686 in reply to 42684
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.

Re: All Commented Out

2005-09-01 15:15 • by Fregas
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.

Re: All Commented Out

2005-09-01 15:17 • by Sean
42688 in reply to 42687
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.

Re: All Commented Out

2005-09-01 15:26 • by Matt B
42690 in reply to 42675
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!

Re: All Commented Out

2005-09-01 15:32 • by Mung Kee
42691 in reply to 42687
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.

Re: All Commented Out

2005-09-01 15:34 • by David
42692 in reply to 42682

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.

Re: All Commented Out

2005-09-01 15:41 • by 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 = "<!--"
lblIStart4.Visible = ( 1 = 1 ) and ( 1 <> 0 )
lblIEnd4.Text = "-->"
lblIEnd4.Visible = ( 1 = 1 ) and ( 1 <> 0 )

If quoteRequest.GuidelineException > GuidelineExceptions.Minor Then
lblIStart5.Text = "<!--"
lblIStart5.Visible = ( 1 = 1 ) and ( 1 <> 0 )

lblIEnd5.Text = "-->"
lblIEnd5.Visible = ( 1 = 1 ) and ( 1 <> 0 )

End If
End If
There, I think that's much better.  (Who wants to pat me on the back?)

Re: All Commented Out

2005-09-01 15:51 • by Mike R
42694 in reply to 42693
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 = ""
lblIEnd4.Visible = ( 1 = 1 ) and ( 1 <> 0 )

If quoteRequest.GuidelineException > GuidelineExceptions.Minor Then
lblIStart5.Text = ""
lblIEnd5.Visible = ( 1 = 1 ) and ( 1 <> 0 )

End If
End 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.

Re: All Commented Out

2005-09-01 15:52 • by scheky
42695 in reply to 42687

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.

Re: All Commented Out

2005-09-01 15:55 • by John Smallberries
42696 in reply to 42692
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?!

Re: All Commented Out

2005-09-01 15:58 • by iAmNotACantalope
42697 in reply to 42694
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 = ""
lblIEnd4.Visible = ( 1 = 1 ) and ( 1 <> 0 )

If quoteRequest.GuidelineException > GuidelineExceptions.Minor Then
lblIStart5.Text = ""
lblIEnd5.Visible = ( 1 = 1 ) and ( 1 <> 0 )

End If
End 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 ;) 

Re: All Commented Out

2005-09-01 16:02 • by Mike R
42699 in reply to 42697
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!

Re: All Commented Out

2005-09-01 16:07 • by Blackhawksq
42700 in reply to 42697
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...

Re: All Commented Out

2005-09-01 16:12 • by David
42701 in reply to 42696

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. 

First time I've been rendered speechless...

2005-09-01 16:18 • by tw000
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.

Re: All Commented Out

2005-09-01 16:19 • by Mung Kee
42703 in reply to 42701
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.

Re: All Commented Out

2005-09-01 16:24 • by K

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

Re: All Commented Out

2005-09-01 16:26 • by dubwai
42705 in reply to 42703

Mung Kee:

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


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

Re: All Commented Out

2005-09-01 16:26 • by PaulaBean
42706 in reply to 42703
Brillant...

Re: All Commented Out

2005-09-01 16:30 • by John Smallberries
42708 in reply to 42701
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.



Re: All Commented Out

2005-09-01 16:33 • by John Smallberries
42709 in reply to 42703
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? [;)]





Re: All Commented Out

2005-09-01 16:40 • by Mung Kee
42710 in reply to 42709
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.

Re: All Commented Out

2005-09-01 16:45 • by Maurits
42711 in reply to 42708
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.

Re: All Commented Out

2005-09-01 16:49 • by Mung Kee
42713 in reply to 42711
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.

Re: All Commented Out

2005-09-01 16:55 • by JamesCurran
42714 in reply to 42708

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. 

Re: All Commented Out

2005-09-01 16:57 • by azaris
42715 in reply to 42693
iAmNotACantalope:




  lblIEnd4.Visible = ( 1 = 1 ) And ( 1 <> 0 )





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



  lblIEnd4.Visible = ( 1 = 1 ) AndAlso ( 1 <> 0 )



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):



If (checkFor = True AndAlso 1 = 1 AndAlso 1 <> 0 AndAlso Black <> White...) Then



Re: All Commented Out

2005-09-01 17:25 • by Daniel T
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">guidelinesa>
for more information

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 :-)

Re: All Commented Out

2005-09-01 17:27 • by 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.

Re: All Commented Out

2005-09-01 17:51 • by Arachnid
42723 in reply to 42715
azaris:
iAmNotACantalope:




  lblIEnd4.Visible = ( 1 = 1 ) And ( 1 <> 0 )





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



  lblIEnd4.Visible = ( 1 = 1 ) AndAlso ( 1 <> 0 )



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):



If (checkFor = True AndAlso 1 = 1 AndAlso 1 <> 0 AndAlso Black <> White...) Then






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.

Re: All Commented Out

2005-09-01 18:25 • by md2perpe
Hmm... Those programmers that write "WTF-code" are really innovative...

Re: All Commented Out

2005-09-01 18:43 • by brazzy
42725 in reply to 42724
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".

Re: All Commented Out

2005-09-01 19:00 • by Maurits
42727 in reply to 42723
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.

Re: All Commented Out

2005-09-01 19:13 • by bugsRus
42728 in reply to 42718
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!



Re: All Commented Out

2005-09-01 19:31 • by ammoQ
42729 in reply to 42728
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

Re: All Commented Out

2005-09-01 20:29 • by Michael Casadevall
42731 in reply to 42729
*twichs*

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

Re: All Commented Out

2005-09-02 05:03 • by ray
42736 in reply to 42686
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!!!!

Re: All Commented Out

2005-09-02 05:37 • by Oha Ooh
42739 in reply to 42736

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.

Re: All Commented Out

2005-09-02 06:00 • by rikkus
42740 in reply to 42723
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?



Re: All Commented Out

2005-09-02 06:14 • by ammoQ
42741 in reply to 42740
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.

Re: All Commented Out

2005-09-02 06:49 • by dhromed
42742 in reply to 42741
I think I actually got a slight bit dizzy when reading this WTF.

« PrevPage 1 | Page 2Next »

Add Comment