How to Write Bad Java Code
summary
Shows concrete fixes: replace repeated string concatenation that creates ~7 temporaries and O(n^2) behavior with a string builder, prefer Optional.ofNullable(...) and maps over nested null checks for safe city lookup, avoid repeated boxing/unboxing in hot loops or use int-streams, compile regex once outside loops instead of recompiling each iteration, let the JVM JIT handle method inlining when possible, and use AtomicInteger or finer-grained locking instead of synchronizing whole methods; mentions Azul VMs and the tool code inventory.
AI-written summary · about
chapters (12)
- 0:00Introduction
- 1:56AI bad code risks
- 2:37String concatenation pitfalls
- 4:20String vs StringBuilder
- 5:43Production testing tools
- 6:23Pyramid of doom with Optional
- 7:48Boxing overhead in loops
- 9:13Regex compilation in loops
- 10:57Method calls in loops
- 13:25Invariant code outside loops
- 14:06Unnecessary synchronization
- 14:48Q&A
related talks
45mHow difficult can it be to write efficient code?
34mFunctional Programming Anti-Patterns in Java
01h 05mJava 8: The Good, the Bad and the Ugly
57mTen Common mistakes made in Functional Java
46mHow difficult can it be to write efficient code?
01h 00mLatest Java Best Practices
47mTwelve Ways to Make Code Suck Less
57mBreaking Java Stereotypes: It's Not Your Dad's Language Anymore
