Live data from Hacker News

How terrible code gets written by sane people

chrismm.com

101–110 of 151 posts

Re: How terrible code gets written by sane people

#101
post #50

Earlier quoted context omitted.

Yes, sorry I should have been more explicit. Initial reviews have value (is this guy full of beans or does he know what he's doing), but constant reviews of senior developer code do not. If you've hired anyone you have to constantly do reviews for, you've probably hired the wrong person. I mean they should get what you are looking for after a month or two.

I know exactly zero developers senior enough to have gotten over writing bugs. I know I've written bugs that happened to pass all my tests only to blow up in somebody else's face, sometimes after surviving years of production use. Code review would've at least had a chance to catch them early—so long as you treat it as critical analysis of program logic and not just a screen for generic goodness. IMO if your code rev…

>I know exactly zero developers senior enough to have gotten over writing bugs.

No one was arguing that. Code reviews aren't for bug discovery, though that can sometimes happen. It's a very inefficient way to discover bugs.

Developers should test their code for bugs before completing the task and submitting to QA. QA is a more thorough than development bug / unit testing and includes integration. Betas (if applicable) are the final source of pre-release bug discovery. Spending a bunch of time on code reviews to find bugs.

IMO code reviews should do two things:

1. Make sure the developer knows how to develop and is not being sloppy and not following whatever standards are set (comments, etc). They are essentially training wheels for new developers to the organization and junior developers.

2. Make sure the code represents what the developer thinks it does (sanity check).

Re: How terrible code gets written by sane people

#102

Earlier quoted context omitted.

I think a lot of this sentiment overlooks the fact that in most cities the number of software companies is very limited - perhaps allowing one switch in a career if there are huge problems or conflicts, but certainly not enough to allow switching due to e.g poor development practices. What's worse, in these places the poor devs tend to stick around while talented ones leave because they either accept moving or they c…

you are removing a lot of personal responsibility from the guy who is looking for the job. If you are born in a 'bad' place (regardless of the reason for it being 'bad' - a violent/poor neighborhood, a city without hope for jobs, a small country-side town with no tech industry at all, etc. etc.) - you should be responsible for improving your life/moving to a better city/etc. to analogize from soccer: Messi plays at B…

> If you are born in a 'bad' place (regardless of the reason for it being 'bad' - a violent/poor neighborhood, a city without hope for jobs, a small country-side town with no tech industry at all, etc. etc.) - you should be responsible for improving your life/moving to a better city/etc.

Most people born in bad places can't get out of them in large part because they're bad, since the effects of that propagate through. Why should the responsibility for a bad place, and subsequently improving it or getting out of it be placed on a person who wasn't the one to make it bad?

People who can get out of bad places are the lucky ones.

Re: How terrible code gets written by sane people

#103

I like the article but I found the implied solution a little humorous. Just hire devs who are great coders, great communicators, stubborn enough to push back against upper management, good hearted enough to sacrificed their own KPIs to focus on the success of their project, and massochistic enough to stick it out at an obviously poorly run project. Good luck Side note, for 15 years of experience the project doesn't s…

I wrote two mails yesterday which basically "push back against upper management", for a very good reason. At least that's what I think. Now I'm totally terrified about what will happen tomorrow. I have 4 kids and almost no money in the bank.

Re: How terrible code gets written by sane people

#104
post #28

Earlier quoted context omitted.

It appears that way short term, but long term, having a bad codebase can retard a company's growth through lack of scalability and maintainability (read easily add/remove/change features). Companies spend a hell of a lot of money for growth. If they don't know how to manage software development, then the software will nullify all that cost spend on growing, because the system can't handle it. I am truly amazed at how…

> It's simply old fashioned thinking. CEOs are typically older, and the current crop were trained before computers really proliferated business. It's really not this at all. It's not a generational thing and it's not an old-fashioned thing. The ultimate rule of workplace dynamics is whether your position is seen as a cost center or a profit center. In software, most often your job is treated as a cost center. My comp…

> The ultimate rule of workplace dynamics is whether your position is seen as a cost center or a profit center.

You are right and this should be one of your top check boxes when looking at a potential employer.

Re: How terrible code gets written by sane people

#105
post #86

Earlier quoted context omitted.

> My theory is that all software eventually becomes difficult to maintain and full of warts, regardless of smartness, regardless of conditions. I agree. I think there's a lot of emphasis on preventing bad code from existing. But if you believe some bad code is inevitable, then it's more important to make it easy to fix when it happens. By default, good code tends to be modular and easy to replace, while bad code is e…

> I agree. I think there's a lot of emphasis on preventing bad code from existing. But if you believe some bad code is inevitable, then it's more important to make it easy to fix when it happens. Indeed, what matters isn't writing bad code, but doing so in a way that affects the whole codebase (whether through coupling or by volume). Accepting that bad code happens helps a lot in locking it down behind containment me…

This is a great talk. I find that this pattern comes up over and over again: first add new code in a safe way that makes the codebase a bit messier without modifying anything, then move all functionality to the new code and neuter the old stuff, then delete the old stuff. Eg this style of pattern is how to do schema migrations safely.

Re: How terrible code gets written by sane people

#106
post #51

It feels like people are focusing on bad conditions and unreasonable deadlines, and not the idea that in the real world smart people under execellent conditions do this very, very frequently. I've worked for long periods of time in 3 codebases that were over 2 million loc in my career, all had great conditions, all had very smart people. Those are not huge codebases by any standard, and yet all 3 had people talking a…

Where does bash require a space in place of a tab? I've got 1000s of lines of scripts that start with #!/bin/bash and 100% use tab to indent.

Re: How terrible code gets written by sane people

#108
post #106
post #51

It feels like people are focusing on bad conditions and unreasonable deadlines, and not the idea that in the real world smart people under execellent conditions do this very, very frequently. I've worked for long periods of time in 3 codebases that were over 2 million loc in my career, all had great conditions, all had very smart people. Those are not huge codebases by any standard, and yet all 3 had people talking a…

Where does bash require a space in place of a tab? I've got 1000s of lines of scripts that start with #!/bin/bash and 100% use tab to indent.

Indented here-strings.

Re: How terrible code gets written by sane people

#109
post #99

Earlier quoted context omitted.

Deadlines are poisson for code quality. I'm pretty sure that much of the code I write today will still be in use ten years from now. There's no point worrying about arbitrary deadlines; in the long run it doesn't matter if the feature was done on time or a month late. What does matter is, for example, wheter all possible error conditions are handled by my code. Fortunately I'm in a position where I can decide not to…

Lovely typo - I am sure such code might show a "poisson" distribution :)

Sounds fishy - I don't buy it.

Re: How terrible code gets written by sane people

#110
post #92

Earlier quoted context omitted.

This is intriguing, and I'd love to hear more context about the team, code, management, and business/product. I really want it to be true and possible in general... I'm going to admit what conclusions I jumped to reading this. I'm admitting my bias, and that I might be wrong, not arguing with you or challenging your experience. My (biased possibly wrong) instinct is to wonder to what degree that was a real world situ…

These projects were explicitly set up to be XP/Agile projects, and were staffed with people with that experience and expertise. The way the experts say you can turn your environment around to that, is by explaining and showing the advantages of a deadline free process. Your management will - not unreasonably - suspect you're just trying to work less hard. The way out of that is to build trust by constantly delivering…

Thanks! Yes, it's hard to do well even under ideal conditions. That fact is what makes me think that usually my biggest obstacle is probably me, even when I'm certain my deadlines are holding me back, and what in turn causes me to project that onto others who complain about deadlines and management.
Post reply on HN