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…
Ask HN: How do I get my team to write better code?
51–60 of 87 posts
Re: Ask HN: How do I get my team to write better code?
#52Great easy read. Cheers
Re: Ask HN: How do I get my team to write better code?
#53Empirically, I've found that methods with ambiguous parameters (e.g. "findEvents(6)") are a much bigger problem (event amongst senior programmers).
Re: Ask HN: How do I get my team to write better code?
#54Re: Ask HN: How do I get my team to write better code?
#55Re: Ask HN: How do I get my team to write better code?
#56I doubt anyone named it the "...last6hours" but then parameterized the number of hours -- so you're changing that code anyway if the number of hours changes. If you have a requirement to parameterize that, do so, otherwise YAGNI, move on.
Hardcoded strings is another one. Frankly, unless you are using the string in more than two places or it's part of a "set" of values, where referencing the full set is useful, you may just be making more work to do it 'correctly'.
You reference timeline pressure. "Good, Fast, Cheap, pick two". If you don't have enough programmers for the timeline alotted, the powers-that-be have already selected Cheap and Fast. Deliver a product that does the job asked, a few maintenance iterations (if the product is one of the 30% that make it that far) will teach you want areas of code are touched a lot and need to be "made maintainable"
Re: Ask HN: How do I get my team to write better code?
#57Reviewing other people's code is almost as valuable as being reviewed. Even if it's not perfect all the time, it builds a good culture of coding and gives your developers valuable experience.
The culture of the code review should be a careful examination with Q&A. You need to take as long as you need to get it right. This is a great investment in your product and your team that will pay off starting right away and extending into the long term.
Re: Ask HN: How do I get my team to write better code?
#58You 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…
It's easy to tell when a manager thinks of you as a "headcount", and it definitely doesn't inspire hard work or quality work.
In the process of connecting with your team as people it should become much more obvious what they need to improve. Sometimes it's encouragement and building confidence (especially for inexperienced devs). Sometimes it's asking questions about what they're trying to do. Also, if you have trust with your team, then offering suggestions for improvement and constructive criticism will be more well received.
The most important thing is to avoid them becoming defensive, and back off or move on when it does happen. It may sound like coddling, but there's a lot of psychological benefits for getting people to see their mistakes and possibly even come up with their own solutions. When people become defensive they come up with reasons to defend what they did, and are blind to the fact that there may be a better way.
Re: Ask HN: How do I get my team to write better code?
#59If the time is so tight that you can dedicate time to fix stuff (including the code quality) then any of the suggestion here are DOA.
Remember: If you want to chop wood for 10 hours, use 8 to sharp the axe.
Code, code, code, code non-stop is as efficient as chop wood without sharp it after a while.
Dedicate time to improve the code quality ALWAYS pay off. Think: "I'm time constrained, so continue the death march until we finish" ALWAYS make the project take longer.
---- A good idea is STOP each week, review the tasks, ask where are the pain, where is the code that is becoming a mess, what is complicated, then FIX that. Decreasing code/clearing it in the short AND long run will be a time saver.
Encourage change when the purpose is quality. Not stick to code/design that is a pain. Stop each week to breathe and see if move forward as now make sense, or is better to kill a portion of the code and rework it.
This is specially important when the TIME is critical. When time is not critical, you can do bad code because, hell, you can take the time! But when you have not time, any bad code is slowing you.
Then make this clear to the team.
Not be yourself the only that code review. Everyone can do it.
Take control when deploy. Not when your customer say so. Be predictable (ie: Always deploy in the start of the week, never at the end).
Re: Ask HN: How do I get my team to write better code?
#60They can take a little while to get set up exactly how you like them, but once you do, run them on your CI server after every commit and it'll output the warnings about style violations and so on. That's basically what you're after. It's not a replacement for a manual code review but it's certainly closer to what you want than nothing!
As other have said though, this only works if you and your team treat code quality as important and actually take the time to understand the output of the analysis tools. That's why I like the CI approach, so that you can see if the number of warnings is going up or down over time and react accordingly. That metric is a useful one to keep an eye on to get a view on the quality of your code, and if it gets too high you can schedule some time.
(PS if you are interested in learning more about "Automatic Code Reviews" for Python, here's a talk I did at EuroPython14: http://carlcrowder.com/pages/europython-2014-automatic-code-... )