Writing beautiful code not just for aesthetic value
-- Attila-Mihรกly Balรกzs
Double Trouble
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
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
Where is my null at?
Double v = null; Double d = true ? v : 0.0d; System.out.println(d);
We come up empty
Collection<V> items; if (items.size() == 0) { ... } if (items.isEmpty()) { ... }
Remove old cruft!
// WRONG! DONâ&#x20AC;&#x2122;T DO THIS! Vector v1; ... if (!v1.contains(s)) { v1.add(s); }
Conclusions
● Effective Java, 2nd edition ● Java Puzzlers ● Modern Perl ● ● ● ●
Sonar Jenkins violations plugin Perl::Critic pep8, pylint
Thank you! Questions? Attila-Mihรกly Balรกzs dify.ltd@gmail.com http://hype-free.blogspot.com/