3 ms·
Terrible article. But even worse, the "fix" was what I would consider a spaghetti hack. They create a HashSet that is mostly never used? The real fix is to cre
by ping_pong 7y ago
Terrible article.
But even worse, the "fix" was what I would consider a spaghetti hack. They create a HashSet that is mostly never used? The real fix is to create the HashSet when you know you need it and don't create it if you don't need it. It sounds like the underlying code has expectations that the HashSet exists and is valid, which in and of itself is bad code.
Check to see if it's null, and if it is null and you need it to not be null, then allocate it then, with size 0 or default capacity, whichever makes more sense.
- hk__2 7y ago> It sounds like the underlying code has expectations that the HashSet exists and is valid, which in and of itself is bad code. How is that bad code? No NPE and other null-related issues, cleaner API, easier to test.
- remote_phone 7y agoThe fact that it cost $500,000 in real money because of this code is more than enough proof that it’s bad code. Plus it’s a small enough change that if it gets modified again, it will cause further money loss.
- hk__2 7y ago> The fact that it cost $500,000 in real money because of this code is more than enough proof that it’s bad code. If this is a proof of anything, it’s that it can be optimized; not that it’s bad code.