- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
lol.. ppl love to reinvent the wheel, and usually with lots of imperfections...
However, I'm all for saying goodbye to DOM and hello to Xlinq. Very eloquent. Very intuitive. The perfect replacement.
Admin
Looking at this makes me want to drink. Heavily.
Admin
Whoa whoa whoa...don't make any major architecture changes to this Enterprise VB.NET app (snicker) so quickly.
First, we need to assign some people to find out what will happen when ex.ToString() does not parse neatly into XML? This code could be called recursively and cause a StackOverflowException! Will this StackOverflowException be caught by the Exception Handler and parsed correctly?
Admin
My God. All they need to do is use frames! Problem solved!
Admin
Admin
Ah, but don't forget:
Since you don't know what's in ex.ToString()....
Admin
You can check this yourself by looking at the resulting IL.
But your point is still good and I'd like to add; People who optimize, rarely know how to.
Admin
Wait! you forgot to place it inside CDATA section Return "<error>" +"<![CDATA[" + ex.ToString() + "]]>" + "</error>" so our error result is not malformed..
hmm.... how bout let's do
String errorXml = "<error>" +"<![CDATA[" + ex.ToString() + "]]>" + "</error>" XmlDocument docError = new XmlDocument(); docError.LoadXml(errorXml); return docError.OuterXml
There... we always get a well-formed xml.. good
Admin
Sure! I charge by the line though....
Admin
Dijkstra said this about the orignal BASIC in the sixties that had only IF ... THEN GOTO as a control structure. The main problem with VB is that it is a bit verbose.
Admin
however it would change "this < that" into "this < that"
Basically it is a complicated way to escape text for xml.
Admin
The real WTF is that in Javascript there is no function to htmlentities() a string, and if you do need to for some reason, your only choice is indeed creating a text node through the dom inside some other container node, then getting it's innerHTML.
P.S. Ok I know this one is not about javascript, I'm just pointing out an even bigger WTF than the one in this story.
Admin
Huh? First, let's separate JavaScript the language from the library for the particular implementation of JavaScript. Nobody expects a language to have a built in facility for escaping HTML so I assume you are complaining about the libraries supplied by the implementation.
Most JavaScript is run within a browser. Why would you need a function to HTML-escape text within the browser environment? Presumably to display the text in the page. Since the best-practice way to display the text is to use the DOM and that already has the escaping built-in there is no need.
If you are not in the browser, you are in an environment like MS JScript(.NET) or Netscape's server side JavaScript. Somebody has already posted how to do this in JScript. I'm not going to do the research for you, but I bet Netscape's server-side JavaScript has something to do this as well.
I imagine TRWTF in this case is that you are using document.write().
Admin
Feh.
Admin
Biting back the comment "by using a whole 'nother language," I thought about this.
Me:"Gosubs?" Interviewer:No. Try again. Me:"Ummmm ... ASTs? Jump tables?" Interviewer:No. Try again. Me:"OK, I fail." It turned out that their entire concept of structured Basic revolved around two concepts, both of indubitable genius:
(1) Write the original code with line numbers spaced at 20, not 10 (thus leaving far more room for patching) and (2) Ensure that every "module" starts on a line number N where N%1000 is zero.
And no, on balance, I suspect that Dijkstra is right and you are wrong. There are always outliers, of course, and you might be one of them. Your comment that you "hear this from conceited programmers all the time" suggests that you are, at the very least, defensive, and indeed that you are still trying to defend your skills in Basic (VB, VB.Net, whatever) for no apparent reason.
Welcome to the world of programmers. We don't mind people who've moved on from BBC Basic; we just object to cleaning up the mess left behind by 90% of the "Basic" community.
Admin
90% of the comments here only point to the fact that Microsoft should stop giving away free IDEs...
Admin
In an imperfect world, at least its organized and in functions. I am maintaining this website where all xml requests are generated via StringBuffers and processing thereof request is handled in the most clumsy fashion imaginable. Now this project commenced in 2006 so jaxb was available, or xmlbeans, or castor...but Bradley(Must be the troll from Dilbert) decided this was the best and quickest solution.
Teaser code :
public String formatRespXml(AbstractBean reqBean, String responseXML) { String formattedXML=""; String postTxn = reqBean.getPostTxn(); if (postTxn == null || postTxn.equals("")) { // retrieve user information to display on application screen String[] values = TxnFactory.getValues(responseXML, UserUtils.PATHS); formattedXML = TxnFactory.createTxnXML(values, UserUtils.NODES); }else{ StringBuffer formattedResponse = new StringBuffer();
I believe with JAXB the code base could be reduced by 40%.
Admin
I don't think that word means what you think it means!
Admin
At one job they asked if we had anything patentable, and I seriously considered submitting our stupid redundancy scheme (which wasn't as redundant as it looked) just so nobody else could do something that stupid without getting sued. I didn't though.
Admin
The real wtf here is that they used .net
Admin
I hate guys who set local variables to null in finally.
Admin
No the real WTF is using Dotnet for string manipulation, way to fancy.
Admin
You mean like "]]"? Using CDATA sections to escape anything unknown i a common WTF.