I had to maintain a js project once that had a very special way of doing things. Can’t post actual code from the project, but it looked something like this:
for(var arrIndex = 0; arrIndex < arr.length; arrIndex++){
for(var arrFooIndex = 0; arrFooIndex < arr[arrIndex].length; arrFooIndex++){
for(var arrFooBarIndex = 0; arrFooBarIndex < arr[arrIndex][arrFooIndex].length; arrFooBarIndex++){
arr[arrIndex][arrFooIndex][arrFooBarIndex]['Property'] = 'yay';
//Lets loop some more ;)
}
}
}
Now imagine this going down up to 10 levels of nesting and add a bit of business logic into each layer, often referencing the objects of other layers. The project was very well documented and structured, but things like this required that you had to be extra careful with every little change. It didn’t help that there was very much redundancy, so often you had to change multiple loop trees, if you needed to change something.
Another thing that annoys me very much (it might be a bit off topic for code style) are date parsers in javascript. Somehow people resist using already established solutions and try to roll their own. And this is really hard to get right, especially if you you take different locales into account. In one project I had to help out with a problem on the frontend with datepickers, I found three different implementations (let’s call them hacks) of a dateParse method, each one used in different places of the application and one of them actually returned the correct dates sometimes… Fun thing is that this application ran on a platform, that had a js api and provided full support for localized dates and some other nice features. But hey, why not roll your own?
I once read a nice quote, sadly I can’t remember where I read it, but it fits nicely for this post: