3 ms·
There's good advice there but you definitely need to not go crazy and get into premature optimization land. If you've got a tight section of critical code like
by ben7799 4y ago
There's good advice there but you definitely need to not go crazy and get into premature optimization land.
If you've got a tight section of critical code like he does this is a good technique, however reuse of the same objects through the critical section implies:
- Mutable objects
- Harder to verify correctness
- Need to be very careful to avoid some very very serious bugs and security issues.
E.x. in his HFT example. Improper reuse of an object without correctly resetting/setting all the fields could create bugs as serious as executing a trade against the wrong user or leaking data between users.
None of this is really rocket science or java-specific. It's all basic old school optimization & computer science.
- peter_lawrey 4y agoMutable objects have their own issues, which can catch people out by surprise. Having good test coverage is important.