5 ms·
Imperfect 'best' Practices
- pnt12 11y agoOne 'best' practice that irks me: "Avoid static methods or attributes in Java". I find static final attributes to be quite good to avoid magic numbers or strings. Static methods also seem better for functional, stateless methods. Why instiate an object when you don't need it? I assume most professionals know when or not to use static. However, most of my university colleagues avoid it like the plague, because every professor says "static is usually bad practice".
- recursive 11y agoMy favorite "best" practice to violate is "All fields must be private."
- MichaelBurge 11y agoI can't remember the last time I've actually made a field private.
- NumberSix 11y agoDijkstra's "Go To statement considered harmful" article spawned a whole series of "XXX considered harmful" papers by various computer science researchers in the following years. This has even led to "Considered Harmful Considered Harmful" counter posts to the practice: http://meyerweb.com/eric/comment/chech.html http://meyerweb.com/eric/comment/chech.html One can argue that these "considered harmful" taboos were largely personal opinions based on the, in retrospect, limited experience with early computers and computer programming projects. Modern computers are over 1000 times faster with 1000 times bigger memory and many other improvements. This, for example, makes scripting languages much more practical than in the 1960's, specifically making run-time type inference and similar implicit/weak typing methods feasible for many programming projects. These typing methods clearly break many of the rules established in the 1960's but empirically make software development much faster in most cases. C++11 caved into fifty years of real-world experience and added type inference with the auto keyword -- for example.