Click here to Skip to main content
15,912,897 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
JokeRe: evil hexadecimal numbers formatting Pin
CPallini2-Oct-08 21:37
mveCPallini2-Oct-08 21:37 
GeneralRe: evil hexadecimal numbers formatting Pin
jamie5503-Oct-08 2:23
jamie5503-Oct-08 2:23 
QuestionRe: evil hexadecimal numbers formatting Pin
CPallini3-Oct-08 2:41
mveCPallini3-Oct-08 2:41 
AnswerRe: evil hexadecimal numbers formatting Pin
jamie5503-Oct-08 2:45
jamie5503-Oct-08 2:45 
GeneralRe: evil hexadecimal numbers formatting Pin
Paul Conrad3-Oct-08 6:24
professionalPaul Conrad3-Oct-08 6:24 
GeneralRe: evil hexadecimal numbers formatting Pin
Louis Cipher10-Nov-08 16:14
Louis Cipher10-Nov-08 16:14 
GeneralRe: evil hexadecimal numbers formatting Pin
Stefano Basili11-Nov-08 3:09
Stefano Basili11-Nov-08 3:09 
GeneralHorrible enough for you? Pin
dojohansen1-Oct-08 4:28
dojohansen1-Oct-08 4:28 
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("block_name").cloneNode(true)); } catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("block_type").cloneNode(true)); } catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("title").cloneNode(true));      } catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("list_id").cloneNode(true));    } catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("format_number").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("format_force").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("visible").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("titre").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("bloc_width").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("bloc_sens").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("bloc_data_type").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("locked").cloneNode(true));} catch(e) {};
try { oXMLRecord.appendChild(oXMLBlock.selectSingleNode("display_type").cloneNode(true));} catch(e) {};


Why have methods when you can just copy-paste the code you need onto each line? And why bother checking such things as if a node exists before trying to do anything with it when you can just catch any exceptions?

This is from a 4165 line javascript file of consistently awful code. The block above is a small sample but there were perhaps three times as many lines just like those where only the name of the child node changes. Another function that could have been somewhat improved had the programmer taken a minute to use an array and a loop rather than his copy-paste approach to everything:

function displayButtonsBlocExistForCell(sCell)
//----------------------------
{
	if(sCell=="A1")
	{
		disableAllButtons()
	}
	else
	{
		if(sCell.substring(0,1)=="A"||isRow1(sCell))
		{					
			disableControlButton("btnBodyColumn");
			disableControlButton("btnBodyLine");			
			disableControlButton("btnBodyText");
			enableControlButton("btnBodyModify");					
			disableControlButton("tdAddNewDocLink1"); 
			disableControlButton("tdAddNewDocLink2");
			disableControlButton("tdAddComment"); 
			disableControlButton("tdDelComment"); 
			disableControlButton("btnEditDelete");	
			if(sCell.substring(0,1)=="A")
			{
				enableControlButton("btnEditInsertRows");
				enableControlButton("btnEditDeleteRows");
				disableControlButton("btnEditInsertCols");	
				disableControlButton("btnEditDeleteCols");							
			}
			else
			{
				disableControlButton("btnEditInsertRows");
				disableControlButton("btnEditDeleteRows");			
				enableControlButton("btnEditInsertCols");	
				enableControlButton("btnEditDeleteCols");					
			};																
		};
	};	
};


Also notice the additional semi-colons..! Sure, it only adds an empty statement and you can write ;;;; anywhere in between statements or declarations in JS without changing anything, but much like the if (myVar == true) bunch it doesn't exactly make you look like you know what you're doing or care much about doing it properly.

(In case anyone don't get the thing with the == true, adding == true to any boolean expression results in another boolean expression that is necessarily equivalent to the original boolean expression. Another, even stupider variant is the ternary myVar? true : false... Sigh.
GeneralRe: Horrible enough for you? Pin
geoffs1-Oct-08 4:43
geoffs1-Oct-08 4:43 
GeneralRe: Horrible enough for you? Pin
dojohansen1-Oct-08 4:48
dojohansen1-Oct-08 4:48 
GeneralRe: Horrible enough for you? Pin
geoffs1-Oct-08 4:56
geoffs1-Oct-08 4:56 
GeneralRe: Horrible enough for you? Pin
BillW331-Oct-08 6:49
professionalBillW331-Oct-08 6:49 
RantRe: Horrible enough for you? Pin
cpkilekofp2-Oct-08 10:01
cpkilekofp2-Oct-08 10:01 
GeneralRe: Horrible enough for you? Pin
BillW332-Oct-08 18:23
professionalBillW332-Oct-08 18:23 
GeneralRe: Horrible enough for you? Pin
cpkilekofp3-Oct-08 2:09
cpkilekofp3-Oct-08 2:09 
GeneralRe: Horrible enough for you? Pin
GibbleCH1-Oct-08 6:06
GibbleCH1-Oct-08 6:06 
GeneralRe: Horrible enough for you? Pin
Paul Conrad1-Oct-08 5:28
professionalPaul Conrad1-Oct-08 5:28 
GeneralRe: Horrible enough for you? Pin
CPallini1-Oct-08 5:34
mveCPallini1-Oct-08 5:34 
GeneralRe: Horrible enough for you? Pin
PIEBALDconsult1-Oct-08 8:51
mvePIEBALDconsult1-Oct-08 8:51 
GeneralRe: Horrible enough for you? Pin
dojohansen1-Oct-08 21:29
dojohansen1-Oct-08 21:29 
JokeRe: Horrible enough for you? Pin
cpkilekofp2-Oct-08 10:04
cpkilekofp2-Oct-08 10:04 
GeneralRe: Horrible enough for you? Pin
VentsyV1-Oct-08 11:46
VentsyV1-Oct-08 11:46 
GeneralRe: Horrible enough for you? Pin
Lutosław1-Oct-08 12:04
Lutosław1-Oct-08 12:04 
GeneralRe: Horrible enough for you? Pin
Paul Conrad1-Oct-08 18:58
professionalPaul Conrad1-Oct-08 18:58 
GeneralRe: Horrible enough for you? Pin
dojohansen1-Oct-08 22:13
dojohansen1-Oct-08 22:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.