Questions tagged [bad-code]
28 questions
196
votes
4 answers
What is an Anti-Corruption layer, and how is it used?
I'm trying to figure out what the Anti-Corruption layer really means. I know that it's a way to transition/work around legacy code or bad APIs. What I don't understand is how it works and what makes it a clean separation from the undesirable…

knownasilya
- 3,074
- 3
- 17
- 16
131
votes
14 answers
Demonstrate bad code to client?
A client has asked me to do a redesign of their website, an ASP.NET Webforms application that was developed by another consultant. It seemed like a relatively straightforward job, but after looking at the code, it's clear that's not the case.
This…

jtiger
- 828
- 2
- 8
- 11
108
votes
11 answers
What kind of bugs do "goto" statements lead to? Are there any historically significant examples?
I understand that save for breaking out of loops nested in loops; the goto statement is evaded and reviled as a bug prone style of programming, to never be used.
Alt Text: "Neal Stephenson thinks it's cute to name his labels 'dengo' " See the…

Anon
- 3,565
- 3
- 27
- 45
100
votes
10 answers
Why is "Select * from table" considered bad practice
Yesterday I was discussing with a "hobby" programmer (I myself am a professional programmer). We came across some of his work, and he said he always queries all columns in his database (even on/in production server/code).
I tried to convince him not…

the baconing
- 1,111
- 2
- 8
- 9
37
votes
13 answers
Worst practices in C++, common mistakes
After reading this famous rant by Linus Torvalds, I wondered what actually are all the pitfalls for programmers in C++. I'm explicitly not referring to typos or bad program flow as treated in this question and its answers, but to more high-level…

Felix Dombek
- 2,109
- 1
- 16
- 24
34
votes
3 answers
Is it OK to return HTML from a JSON API?
On my current project I am responsible for the implementation of a service which involves the consumption of newly created RESTful APIs, documented as solely supporting JSON.
The client consistently makes requests with the accept header of…

phillip.darley
- 443
- 1
- 4
- 7
30
votes
12 answers
What design patterns are the worst or most narrowly defined?
For every programming project, managers with past programming experience try to shine when they recommend some design patterns for your project. I like design patterns when they make sense or if you need a scalable solution. I've used Proxies,…

Akku
- 457
- 1
- 4
- 10
25
votes
8 answers
Is it better to use pre-existing bad practices, or good practices that don't fit well with old code?
I was thinking of this because I was trying to write an extension for an existing 3rd party software, and their database is horribly denormalized. I needed to use their existing tables and add a bunch of new fields.
I had the option of either…

Rachel
- 23,979
- 16
- 91
- 159
23
votes
10 answers
How to prove an application is built on a bad codebase?
I'm currently reviewing a system built by some developers that previously worked at my job. The system works pretty well from a user's point of view, but when delving into code review it's a utter mess. I'm more than convinced that the way the…

ChrisR
- 779
- 1
- 5
- 13
21
votes
6 answers
How do you deal with intentionally bad code?
There are many stories about intentionally bad code, not only on TheDailyWTF but also on SO. Typical cases include:
Having a useless time-wasting construct (e.g. an empty loop counting to some huge value) so programmers can easily "speed up" the…

mafu
- 313
- 2
- 12
20
votes
7 answers
What can you do about the quality of existing integration and unit tests while being the new guy in a team ?
A recurring theme that I came across in my career is being the new developer to arrive in a team, and quickly having an inherent distrust of the existing unit and integration test suites.
During the interview you are told by the management that they…

maple_shaft
- 26,401
- 11
- 57
- 131
16
votes
7 answers
If a fluent coder disregards good practices, doesn't his fluency work against him?
I am working on a fairly large and buggy application - and due to the way it's written (I'll spare you details, but it violates rules in most areas you can think of), it is next to impossible developing it without major refactoring.
Significant part…

Konrad Morawski
- 9,721
- 4
- 37
- 58
16
votes
3 answers
At the end of my rope
I am a contractor to a big company. Currently, there are three developers on the project, myself included.
The problem is the other 2 developers don't really get it. By "it" i mean the following:
They don't understand the best practices for the…

hvgotcodes
- 961
- 8
- 12
14
votes
11 answers
Should you fix preexisting defects while working on something else?
Conundrum: During the course of working on a new feature or fixing a defect, you find a legacy problem in code. What should you do? Fix it and risk altering the behavior of the code. It has either been working up until now by some fluke, or else…

Corey
- 241
- 1
- 2
13
votes
8 answers
Do you write bad code when under pressure?
When you are under pressure, the deadline is approaching, and a manager is breathing down your neck do you find yourself starting to write bad code? Do TDD and best practices slip by the wayside in order to get things done? What do you do in…

ysolik
- 6,340
- 4
- 34
- 50