3 ms·
Common beginner mistake. (Not saying the OP is a beginner, may have had some specific reason, since it says "in his refactored functions".) Other similar ones
by vram22 10y ago
Common beginner mistake. (Not saying the OP is a beginner, may have had some specific reason, since it says "in his refactored functions".)
Other similar ones are things like:
if ((count > 10) == true)
# in any language, not just C, so I'm using generic placeholder for boolean true,
instead of:
if (count > 10)
and inability to grok stuff like:
while not done
(or while not found)
....
# set done or found here based on some condition
- 0xfeba 10y agoThe other 2 devs on my team (both senior to me) routinely check in code like this: function(filename) { if (!filename) { this.setState( {x : null}); } var s = filename; if (s) { this.setState({y :''}); } else { this.setState({z: false}); } } Which to me is unfinished code (I truncated variable names). I always try to cleanup my code before checking in, probably to my detriment. They both are much faster at pushing features out. But god, some of the code is just unreadable. Also--no comments. For some reason everyone at my current company refuses to use comments. And I've seen plenty of: x == true ? true : false ternaries, though in javascript, these are not necessarily redundant and are easy to mistake. A couple other favorites I've seen: if (x == 'true') ... and var data = {option: 1} var context = this; this.someMethod.bind(this, context, data, data.option)
- vram22 10y agoWow. Or rather, !wow. Such practices are all too common ... should be the rare exception, really.