Live data from Hacker News

A Million Lines of Bad Code

varianceexplained.org

71–80 of 123 posts

Re: A Million Lines of Bad Code

#71
I agree that mean-spirited feedback is not helpful/constructive. I can see how that would discourage someone who is new to programming. In fact, "feedback" is probably not even the correct name for that... maybe "bullying".

However, I have to disagree with the notion of having to write a lot of shitty code to learn to write good code. Granted, that is one way to learn, but not nearly the most effective way to learn.

For years, when I started my career, I wrote lots of shitty code. I feel badly about having done this because I unwittingly caused quite a bit of havoc in the products I was working on, and even pissed off a few customers along the way. Writing shitty code can have really bad effects on a team and on a product.

Fortunately for me, I eventually ended up working in an extremely talented team. They were not only talented at programming, but also highly skilled at teaching others good programming. Their method was simple- they accepted nothing that failed to meet their high (and documented) standards of readability and testing, but were extremely thorough in spending time showing you what you did wrong. They were never demeaning and always constructive- they always had a high level optimism in every new-comer's potential. Given enough time, it was clear that some new team members weren't going to work out, but those who had it in them to patiently improve their skills flourished and enjoyed very successful stints with this team.

After a rough first few days on the team, I heeded their warnings and agreed to check my misplaced ego at the door. Then, and after a couple of months of embarrassing ineffectiveness, I gradually became a better programmer and went on to become a great team member. I'm really grateful for the patience these guys had with me and the other noobs. They really made a difference in my career and in the career of my peers!

Re: A Million Lines of Bad Code

#73

Not quite right. All the code I wrote last year looks bad to me; naieve, clumsy, artless. Because I have learned so much since then. It never gets any better. Not because I don't get better; because I DO get better. I've been writing code since 1976.

I hear this sentiment a lot (and notice it in myself, though I have a lot less experience so it hasn't been as long running), and it worries me.

Are you sure it's better? Are you keenly aware that there are no, say, cycles in your coding approach?

I know this year I look back at last year's code and go, "oh boy, why'd I do it that way?" And I feel like it's better, but I'm always a little afraid I'm just chasing novelty. Not sure how to objectively know if it's better.

Re: A Million Lines of Bad Code

#74
one of my first projects as a consultant fresh out of college was HORRIBLY coded by my standards today. Sometimes I still fire it up and it still works (which fills me with pride); however, perusing the code hurts my eyes and I often wonder what was going through my mind.

Re: A Million Lines of Bad Code

#75

Earlier quoted context omitted.

In the martial arts community we call this "praise, correct, praise."

Programmers tend to incline towards efficiency. I think that's why we often skip the bread and deliver only the filling. IMO there's a big difference between a criticism sandwich and tactful criticism.

"Inclining towards efficiency" might be their justification, but I think the truth is closer to many programmers simply lacking tact.

Re: A Million Lines of Bad Code

#76

Earlier quoted context omitted.

Very well said. It's wrong to be a dick, but it's also the natural response to a lot of stressful situations. Think of trying to give tech support to relatives, for example. It's too easy to get annoyed with other people, and this is especially true when you're under pressure and they're MEANT TO BE HELPING, DAMNIT! FWIW, I suspect that you're much more experienced in this stuff than me, so it's a bit arrogant for me…

That's actually the route I've been trying to follow, but that's where the experience gap becomes a problem. I can give him some ressources on how to use Git or learn Python, but it's been so long that I don't even know where to start for the CLI :|

I like this:

http://www.amazon.com/Practical-Guide-Commands-Editors-Progr...

I've also found "Unix for the Impatient" very helpful but the 1995 copyright is a little scary.

Re: A Million Lines of Bad Code

#77
> So I wrote a Perl script that read in the file, combined it, and printed it out as a single line. Then I had my Java program call the Perl script through the command line, capture the printed output, and save that as the string.

When I first started (in Python), I didn't understand what a function was, but I wanted my program to react differently depending on user input, and had some conception that I should be breaking my program up into files by purpose. So what I did to get it working was this: I named each file "$cmd.py", then I concatted the user's input with ".py", opened & read the file with the associated name, and ran the resulting string through exec() !!

I came to this result incrementally by googling different aspects of the problem that I didn't know how to describe properly. If someone had been a jerk to me about it then, I probably would've been really self-conscious about it. But no one was a jerk, so I'm not ashamed: what I did is ridiculous and funny & I'm glad to be able to laugh about it now.

Re: A Million Lines of Bad Code

#78

Earlier quoted context omitted.

This is helpful for sure, but it's also very useful to work on having a thick enough skin to take insulting feedback in a positive fashion. After all, the only way someone can offend you is if you let them.

I'm a junior dev, I have a ton to learn and I don't for a moment think I know more than our senior dev. But working with this guy, and trying to learn from him, is a nightmare. When I ask "why should I do this rather than that?", I either get a muddy explanation, or none at all. Worse still is inconsistency. Just recently I was working on a project, went through several reviews without comment on the approach, was to…

I usually ask more senior people why they say that, and keep asking why until I get it. If this process seems to be going on too long, I ask if there's a book or reference I should be reading to understand the subject better. Honestly, most senior people will be very pleased that you care enough to find out why, including following up with external resources.

If a senior person won't explain something if you ask politely, usually either they don't understand it themselves, or they are simply not very good at explaining things. Not all senior people are good teachers. It sounds like your team lead is one of the latter.

Re: A Million Lines of Bad Code

#79

Earlier quoted context omitted.

I built a string this way in java just 5 years ago. Still made it 100x times faster by using a StringBuilder.

So like 1ms down from 100ms? Either way a rounding error in the episode-of-LOST-average-duration timescale ;)

Why don't you give it a try yourself. Create a file with a high ratio of lines to length, and read it in using a loop and string concat, or builder. Do it with a builder first, when you get up to 1 minute, switch over to concat and see how long it takes.

Re: A Million Lines of Bad Code

#80
post #46
post #6

I recently read the book "How to Win Friends & Influence People", bad title great book. My main take away from this is I've been talking to people really badly for the last 27 years. I wish I had read this book in middle school. But this blog reminded me of some of the concepts from the book, its far more productive to give positive encouragement than to give negative feedback, and just adding a complement isn't enou…

When I read that book by Dale Carnegie one think struck me. Aside from being well with words and advice he never succeeded in his own life. Two divorces and almost no friends at the end of his life. General advice is easy to give. There are millions of tiny details which tend to guide you away.

Sources for that? Wikipedia doesn't mention a divorce with his second wife, Dorothy Vanderpool.
Post reply on HN