|
|
|
Really... sometimes not that I really want to complain... I'm really not sure why it's so hard to realize problems with certain programming code.
// replace \n with "" to replace blocks tempp = dd.data; name_RegEx = new RegExp("\n\n"); name = name_RegEx.exec(tempp); dd.data = tempp.replace(name, " "); Essentially, what this code does is to look for 2 joint new line characters and replace it with a space char. This replacement is required because newline char causes some blocks to show up on the screen. And the primary complaint was this specific example where 2 newline char happen to appear beside each other. So my colleague, happily look for this pattern and replace it. Sure it does solve this problem, and perhaps only this problem. What happens if I have 2 instances of this, eg, "I'm happy.\n\n. So are you.\n\n" ? Or what happens in this case? "See that space in between the newlines? \n \n". It was such a simple fix... and I told myself umpteen times, I should let her fix some bugs without worrying that she'd mess something up... but... sometimes, some people just can't seem to see the flaws of their code... and just fixing the problem and only that problem at hand... no such thing as collateral thinking... and worse, writing code when not knowing what the program is doing... And so, I just replaced that 4 lines of code with a single line: dd.data = dd.data.replace(/\n/gi, " "); which replaces all "\n" with a space char in the given string of characters. Does the same job, and better, with just a single line of code, instead of 4. And yes, she took like half a day to figure that out... It took me only 2 min. Don't know why I had to be the one to fix my own bugs, and then read her code and rewrite her fix to fix her bugs. one peanut salary, double the work. grrr... ok lahz... as a friend and colleague, she's a really nice person la... and can't blame her that she doesn't see the possible flaws too... but despite that... it still gets on my nerves sometimes!!! cos writing the code myself, is much faster and less stress than reading someone's code and rewrite it!!! Now you know why I was so stressed!!! when you have to clean it not only once or twice, but many many times... and no, not talking about just 100-200 lines of code here... it's like 10k-20k lines of code... quite little, but if you have to do it all the time, for simple matters like this... it's arrrrgh!!! buai tahan!!! But I'm glad, it's over... All over!!! |
|
***Try dragging me and my friends *** =)
|
|