19 bad programming practices (many of which I committed myself)
Rafael Chaves
Rafael Chaves
Senior Software Engineer - API, tooling, domain design, core Java, model-driven, OSS
I just realized I have been building software for a living for 19 years now. To celebrate that, here are 19 bad programming practices I have witnessed and sometimes even practiced myself at some point during my career, in no particular order.
- Naming: abbreviations, naming after type instead of role, inconsistent names, failure to use business terminology
- Error handling: swallowing exceptions, using return values to signal errors, failing to protect against error conditions, over-checking for impossible conditions
- Failure to sanitize user-provided data (serialization, query injection, XSS)
- Responsiveness: invoking long-running code in a blocking way - worse if failing to provide progress updates to user
- Domain modeling: devoting too much attention to technology and failing to understand and address the business domain, failure to properly model the business domain in the code
- Lack of proper separation of concerns (coupling independent business concerns, or coupling business and technology concerns)
- Configuration in code, user credentials in code
- Reliance on an IDE to produce builds
- Premature optimization
- Comments: describe the code but not the intent, lack of comments, too many comments
- Keeping code around for features that are no longer or have never been needed
- Testing: failing to create good test coverage for non-trivial code, checking in a new test case that has never failed, having a test case call other test cases for data setup, writing to stdout instead of producing an actual test failure, getting used to having a test case that is known to fail once in a while
- Over-aggressive locking or not protecting data enough against concurrent access
- Attempting to fix a bug without reproducing it reliably first
- Committing changes meant to address multiple issues/features as a single change set, failure to provide a commit message that explains the rationale behind the change, mixing reformatting (including choice of line terminator or indentation character) with actual code changes
- Failing to isolate dependency on specific technical solutions (a database product, or a data storage paradigm) so it spreads throughout the codebase
- Creating own solutions for problems that already have solutions that are widely available (NIH, obliviousness)
- Failure to honor existing/prevailing style in the codebase
- Copying code from an open-source project off the internet and sticking it into a commercial codebase
Any others that you have seen but I missed?
By the way, we can help boost your team's throughput by building entire tools, backend modules or micro-services for your product. If you are interested, please send a note to [email protected].
Senior Software Developer
6 年Great list! I remember seeing a few of these recently. # 14 is an interesting challenge; sometimes you're asked to fix a bug that cannot be easily reproduced, such as performance issues. Often I have found that most of the time spent fixing such a bug is actually spent in trying to reproduce it. Once you know what the issue is, (if you can even find the issue) it is but a moment's work to fix.
Director - Intelligent Automation | Senior Project & Account Manager
6 年Excellent, and very well placed. Thank you. My rule, "Design by Contract".