Horrible enough for you?
-
I normally "tweak" or just plain replace old code that may work, but is really bad code. I don't always have enough time to replace as much bad code as I would like, but I do it whenever possible. Bill W
CIDev wrote:
I normally "tweak" or just plain replace old code that may work, but is really bad code. I don't always have enough time to replace as much bad code as I would like, but I do it whenever possible.
I know what you mean :( I'm in the process of finally, COMPLETELY refactoring an application created by an entry-level programmer in .NET 1.0. It's not terrible, considering her skill level and the state of Visual Studio.NET at that time, but it wasn't good. I'm guessing that the size of the code in both .aspx and .aspx.vb files has decreased by half. It only took me four years to get enough knowledge of .NET and ASP.NET, then to get permission to go for it :laugh:
-
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");