Which programming “best practice” do you think is actually wrong?
AI Signal Decode
The discussion centers on the principle of "separation of concerns," with a strong counter-argument that "locality is more important" and that code frequently modified together should be physically co-located. This challenges established practices like separating HTML, CSS, and JavaScript into distinct files, with participants suggesting that single-file component approaches, as seen in modern web frameworks and web components, are more effective. The debate extends to testing, questioning whether co-locating tests with code, as in Rust, or separating them into distinct projects, as in some .NET architectures, is superior. This challenges developers to reconsider the fundamental organization of their projects based on maintainability and developer experience.
Market implications and developer productivity are key concerns. The critique of microservices, for instance, highlights how architectural "best practices" can be misapplied, leading to "spaghetti architecture" and increased complexity for internal tools where massive scale isn't required. Similarly, the debate on "100% test coverage" acknowledges its value for foundational systems but questions its economic feasibility for typical user-facing software. The conversation implies that choosing the right level of abstraction and adherence to principles based on project context, rather than universal application, can significantly impact development speed, cost, and the overall success of a software product.
Technically, the conversation delves into specific patterns and their perceived shortcomings. The idea that "code that changes together should live together" suggests a preference for co-location over strict logical separation when dealing with tightly coupled functionalities. This is exemplified by the preference for finding test files in easily discoverable locations (e.g., same directory with a '.spec' suffix) rather than hunting them across complex project structures. Furthermore, the critique of never using single-character variable names is challenged by the argument that variable naming conventions should adapt to scope, with short names being acceptable and even beneficial for highly localized variables, especially in concise functions or specific programming paradigms.
Moving forward, the key takeaway is the emphasis on pragmatism over dogma in software development. Developers should critically evaluate established "best practices" against the specific needs and context of their projects. Future discussions will likely continue to explore nuanced approaches to code organization, testing strategies, architectural decisions (like microservices vs. monoliths), and coding conventions. The convergence towards single-file components in web development and the ongoing debate about the ideal balance between code isolation and co-location will remain central themes as the industry seeks more efficient and maintainable ways to build software.