Click here to Skip to main content
15,887,585 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.

 
RantRe: Another piece of MS Office Brilliance Pin
kmoorevs28-Jan-15 9:21
kmoorevs28-Jan-15 9:21 
GeneralRe: Another piece of MS Office Brilliance Pin
PIEBALDconsult30-Jan-15 3:05
mvePIEBALDconsult30-Jan-15 3:05 
GeneralRe: Another piece of MS Office Brilliance Pin
BillW3330-Jan-15 4:44
professionalBillW3330-Jan-15 4:44 
GeneralRe: Another piece of MS Office Brilliance Pin
PIEBALDconsult30-Jan-15 4:48
mvePIEBALDconsult30-Jan-15 4:48 
GeneralRe: Another piece of MS Office Brilliance Pin
BillW3330-Jan-15 7:19
professionalBillW3330-Jan-15 7:19 
GeneralRe: Another piece of MS Office Brilliance Pin
User 101325462-Feb-15 21:50
User 101325462-Feb-15 21:50 
QuestionRe: Another piece of MS Office Brilliance Pin
ZurdoDev30-Jan-15 7:47
professionalZurdoDev30-Jan-15 7:47 
GeneralI fix it!!!111 Pin
BuggyTimes30-Dec-14 5:21
BuggyTimes30-Dec-14 5:21 
We have two functions apiCall and handleChangeEvent. The simplified version below.

JavaScript
function apiCall() {
    // smart stuff here
}

function handleChangeEvent(newData,oldData) {
    if(newData !== oldData) 
    {
        apiCall();
    }
}


One of my colleagues reports they have a problem with apiCall not being called from handleChangeEvent because of the if condition. They claim that the event is sometimes handled and sometimes not. Suspicious claim, as the apiCall code can be triggered from other locations, but it's an issue they should be able to handle so I didn't investigate further.

Later the cheery colleague says they solved the issue and I decided to review their code. I take a look at their work from time to time to help improve their code and this is the solution they came up with:

JavaScript
function handleChangeEvent(newData,oldData) {
    newData = !oldData;
    if(newData !== oldData) 
    {
        apiCall();
    }
}


WTF | :WTF: Cry | :((

I told them that this is not the way to solve the issue, and took the time to show them that that apiCall was in fact called from another location. I also gave them a few solutions that could be made and left to take a break. I hope to help guide them, but I fear that there is no helping them Sigh | :sigh: . I'm still puzzled and angry that someone would write such a solution!?
GeneralRe: I fix it!!!111 Pin
Slacker00730-Dec-14 5:38
professionalSlacker00730-Dec-14 5:38 
GeneralRe: I fix it!!!111 Pin
Claies30-Dec-14 11:17
Claies30-Dec-14 11:17 
GeneralRe: I fix it!!!111 Pin
BuggyTimes5-Jan-15 1:11
BuggyTimes5-Jan-15 1:11 
GeneralRe: I fix it!!!111 Pin
Ray Raymos6-Jan-15 14:34
Ray Raymos6-Jan-15 14:34 
GeneralRe: I fix it!!!111 Pin
BuggyTimes16-Jan-15 1:33
BuggyTimes16-Jan-15 1:33 
GeneralRe: I fix it!!!111 Pin
Freak3020-Jan-15 0:46
Freak3020-Jan-15 0:46 
GeneralRe: I fix it!!!111 Pin
BuggyTimes20-Jan-15 1:06
BuggyTimes20-Jan-15 1:06 
QuestionRe: I fix it!!!111 Pin
CHill6012-Jan-15 3:54
mveCHill6012-Jan-15 3:54 
AnswerRe: I fix it!!!111 PinPopular
ZurdoDev12-Jan-15 4:10
professionalZurdoDev12-Jan-15 4:10 
GeneralRe: I fix it!!!111 Pin
CHill6012-Jan-15 4:26
mveCHill6012-Jan-15 4:26 
GeneralRe: I fix it!!!111 Pin
Ray Raymos18-Jan-15 13:36
Ray Raymos18-Jan-15 13:36 
GeneralRe: I fix it!!!111 Pin
BuggyTimes20-Jan-15 1:07
BuggyTimes20-Jan-15 1:07 
GeneralNew record... Pin
Kornfeld Eliyahu Peter21-Dec-14 11:14
professionalKornfeld Eliyahu Peter21-Dec-14 11:14 
GeneralRe: New record... Pin
Sander Rossel21-Dec-14 11:22
professionalSander Rossel21-Dec-14 11:22 
GeneralRe: New record... Pin
Kornfeld Eliyahu Peter21-Dec-14 11:27
professionalKornfeld Eliyahu Peter21-Dec-14 11:27 
GeneralRe: New record... Pin
Sander Rossel21-Dec-14 11:35
professionalSander Rossel21-Dec-14 11:35 
GeneralRe: New record... Pin
Deflinek22-Dec-14 2:35
Deflinek22-Dec-14 2:35 

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.