CodeSOD: A Private Matter
by Remy Porter from The Daily WTF on (#55GCG)
Tim Cooper was digging through the code for a trip-planning application. This particular application can plan a trip across multiple modes of transportation, from public transit to private modes, like rentable scooters or bike-shares.
This need to discuss private modes of transportation can lead to some... interesting code.
// for private: better = sameTIntSet myPrivates = getPrivateTransportSignatures(true);TIntSet othersPrivates = other.getPrivateTransportSignatures(true);if (myPrivates.size() != othersPrivates.size() || ! myPrivates.containsAll(othersPrivates) || ! othersPrivates.containsAll(myPrivates)) { return false;}
This block of code seems to worry a lot about the details of othersPrivates, which frankly is a bad look. Mind your own business, code. Mind your own business.
[Advertisement] Ensure your software is built only once and then deployed consistently across environments, by packaging your applications and components. Learn how today!