4 ms·
Is it really an anti-pattern when you're just writing code that depends on equality without understanding how equality works? There's probably a lesson to be l
by andrewingram 11y ago
Is it really an anti-pattern when you're just writing code that depends on equality without understanding how equality works?
There's probably a lesson to be learned in here, but if I wrote an article every time I wrote bad code, I wouldn't have time to write any bad code ;)
Edit: This particular issue is pretty common, and it's good to draw attention to it, but let's just call it what it is - a common bug.
- masklinn 11y ago> Is it really an anti-pattern when you're just writing code that depends on equality without understanding how equality works? The issue here mostly being that PureRenderMixin uses identity because Javascript has little to no support for equality.
- TheCoelacanth 11y agoThe real anti-pattern is languages without value types.
- ashearer 11y ago"Anti-pattern" sounds close enough, as shorthand, when "bug" might cause readers to file the article incorrectly. The author is warning others that a normally-unremarkable JavaScript idiom causes suboptimal performance in this particular case, and it's likely not to present itself as a bug (having no visible symptoms on smaller pages and no impact on functionality otherwise). Putting aside whether suboptimal performance should always be classified as a bug, there are many ways to accidentally break equality comparisons (despite a full understanding of them), and now my eyes are primed to catch one more pitfall. I appreciate when that happens for reason that doesn't involve hard experience.
- andrewingram 11y agoI think calling it a common pitfall might be the most descriptive. I've certainly made the mistakes the article mentions, but I'd never have considered it a pattern. To me a pattern in this context is a repeated practice, workflow or solution.