![Page 1: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/1.jpg)
Writing beautiful codenot just for aesthetic value
-- Attila-Mihály Balázs
![Page 2: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/2.jpg)
Double d1 = (5.0d - 5.0d) * 1.0d;Double d2 = (5.0d - 5.0d) * -1.0d;System.out.println(d1.equals(d2));
double d1 = (5.0d - 5.0d) * 1.0d;double d2 = (5.0d - 5.0d) * -1.0d;System.out.println(d1 == d2);
Double Trouble
![Page 3: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/3.jpg)
BigDecimal d1 = new BigDecimal("1.2");BigDecimal d2 = new BigDecimal("1.20");System.out.println(d1.equals(d2));
* http://hype-free.blogspot.ro/2008/12/negative-zero-what-is-it.html
Double Trouble
![Page 4: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/4.jpg)
Double v = null;Double d = true ? v : 0.0d;System.out.println(d);
Where is my null at?
![Page 5: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/5.jpg)
Collection<V> items;
if (items.size() == 0) { ... }
if (items.isEmpty()) { ... }
We come up empty
![Page 6: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/6.jpg)
// WRONG! DON’T DO THIS!Vector v1;...if (!v1.contains(s)) { v1.add(s); }
Remove old cruft!
![Page 7: Writing beautiful code - not just for aesthetic value](https://reader031.vdocuments.mx/reader031/viewer/2022020219/568bd7db1a28ab2034a140d4/html5/thumbnails/7.jpg)
● Effective Java, 2nd edition● Java Puzzlers
● Modern Perl
● Sonar● Jenkins violations plugin● Perl::Critic● pep8, pylint
Conclusions