Live data from Hacker News

Ask HN: How do I get my team to write better code?

news.ycombinator.com

71–80 of 87 posts

Re: Ask HN: How do I get my team to write better code?

#71

You need to stop thinking of them as 'coders'. When you think of them that way, you're putting them in a box and limiting them. Instead consider them to be a team of people. As you said, each of them are at different stages in their career in programming. You need to understand this and sympathize with them and their code. This takes time and effort on your part to help lead the way. You say that you review the commi…

You're very right about the coders bit - I guess it was more an issue of framing it. I've corrected it now. I do bring the issues up - but usually end up being really frustrated because I assume that these things should be obvious. A lot of the comments in this thread are forcing me to reflect though, and realize that I didnt "know" those things out of the box either - but learned them by seeing others' good code and…

> I assume that these things should be obvious.

I'm glad that you've gotten so many takeaways but be very mindful of this. As you've said you didn't see a lot of these things when you just started out. It's through experience that things became obvious.

It'll take time but if you focus on teaching and improving your team you will get there.

Re: Ask HN: How do I get my team to write better code?

#72
Sometimes it's more about learning clever architecture than clever, or better code. Clever architecture can often help keep your code an order of magnitude simpler.

The issue you may run into is seasoned developers are the ones who learn this over time.

Conversations based around "why" help a team understand the importance of:

- creating a codebase that they will still want to / be able to work on without dealing with poor decisions of the past, o

- being kind to your future self

- realizing not everyone has had a relationship with a codebase for 3, 5, or even 10 years and what that might look like. In the real world, existing code bases are a reality. Optimizing for that reality, instead of the clean slate that university assignments, or startups provide can also be an important light bulb.

- peer reviews, and teaching the why you do things a certain way are far more likely to get the lasting result you are seeking.

Re: Ask HN: How do I get my team to write better code?

#73
post #69

Earlier quoted context omitted.

this is great - I love coding in Python and would definitely use this in the future. Currently we're doing everything in Node.JS though - do you know of any tools for that ? We do use Jslint etc - but landscape certainly seems to go a step further..

You should check out https://codeclimate.com/ then, they support JS and Ruby. There's also https://scrutinizer-ci.com/ who do PHP and apparently Python and Ruby now too.

https://www.codacy.com/ supports JS, PHP, Scala, Python and CSS

Re: Ask HN: How do I get my team to write better code?

#74

Try having your team read these books: http://www.amazon.com/Writing-Solid-Code-Microsoft-Programmi... http://www.amazon.com/Practice-Programming-Addison-Wesley-Pr... http://www.amazon.com/Code-Complete-Practical-Handbook-Const... I know these are old books and are C and C++ oriented, but it helped me a lot during my formative years and helped me transition from being a decent programmer to being a decent engineer. T…

Code Complete has 960 pages, not in the short book category

Re: Ask HN: How do I get my team to write better code?

#77

I honestly think this complaint is poorly argumented. It depends on the nature of the project. When you say "findeventsfromthelast6hours" that's perfectly reasonable name for disposable code or private implementation. You should only be concerned about such name if it made it to the API somewhere. Hardcoding things is also not a bad thing by itself. If I had to guess, your team is under the impression the code they w…

Indeed, I think Robert Martin's "Clean Code" would agree that if you don't need to vary the "6 hours" part at run-time, then "findeventsfromthelast6hours" is actually better than passing in an "hours" argument ("Clean Code" advocates minimizing function arguments). Refactoring the name in the face of a one-time change in behavior (e.g. "4hours") should be trivial with any modern IDE.

Re: Ask HN: How do I get my team to write better code?

#78
To me, this is the difference between being a programmer and a software engineer. Software engineers think of the bigger picture and understand the overall impact of choices made in the code on other things. Programmers focus too much on just coding and don't see the bigger picture.

I am sure much of this has to do with experience and having had the opportunity to learn from good software engineering teams.

In my teams, I have handled this with mentorship. Recognize who in the team needs mentoring and assign them a code review buddy. If mentorship somehow doesn't work, you just have to manage those programmers and put them under tighter supervision. However, you can't expect much change until you set and communicate expectations. Be clear on what you expect and review against those benchmarks.

Re: Ask HN: How do I get my team to write better code?

#79
post #47

I review commits now and then and find some of these issues - but due to the nature and timeline fo the project cannot do it for each and ever commit of course. Why not? I do. I have 8 direct reports and I review every single line of code that they write. Some days this is all I do. Others think I'm crazy but our group outperforms every other group by any measure. I'm convinced it's because of peer review. A few thou…

+1 100% peer review is the only process change that has been implemented anyplace I've worked in the last 18 years that seriously and lastingly improved code quality. I don't like reviewing, but it's very very effective, especially once you get good at it (and, like anything, it takes practice) - also, fwiw, it really improves you own coding

I agree completely and I would add that you need to keep the review size reasonable for this to work. I've been asked to review thousands of lines of code at once and it doesn't take long before your eyes glaze over and you start missing things.

Re: Ask HN: How do I get my team to write better code?

#80
My advice is that before you propose solutions, you ought to really figure out what the problem is. Is it ignorance, laziness, or something else? I've looked over the various responses and haven't seen one angle -- have you asked your team about why they are not doing what you'd like? There's a lot of advice about read this, do that, etc. but you don't yet know why they are not following what you think is common sense. You might find something surprising by putting it on the table, or at least you'll find the reasons they give. Then you can address those. My advice is to put this out as a question to your team and see how they react. You might even find out that some of the patterns you think are best are not, i.e., your team has a reason you didn't think of. For example, I created a 10-element array to speed the search of a big table in which all keys began with a digit from 0-9. The more experienced guy told me that in the .NET world, the convention was to use key-value pairs instead of an array. To satisfy him, I changed it to a hash table, where I hashed the first digit. It seemed pretty silly to me, making a hash table for what to me was clearly a better approach using a simple indexed array. He had in his mind the "right" way to do it, eventhough I still think the hashtable in this case was silly.
Post reply on HN