CODING TEAM THEORY: How do you deal with another developerโs bad code?
๐ how do you flag that up when the bad code was written by your teammate?
1๏ธโฃ ๐ฆ๐๐ฏ๐ท๐ฒ๐ฐ๐๐ถ๐๐ถ๐๐ ๐๐๐ฐ๐ธ๐ โ
Before you get any closer to questioning someone elseโs work, itโs important to check that your objection to their method is valid.
This means that you need to analyze why you think their code sucks.
2๏ธโฃ ๐๐ฑ๐ฒ๐ป๐๐ถ๐ณ๐ ๐๐ต๐ฒ ๐ฝ๐ฟ๐ผ๐ฏ๐น๐ฒ๐บ
There needs to be an objective problem with the code:
๐ Itโs consistently buggy
๐ Itโs written in an inefficient way
๐ It doesnโt meet the companyโs coding standards
3๏ธโฃ ๐๐ฌ๐ค๐ข๐ง๐ ๐ช๐ฎ๐๐ฌ๐ญ๐ข๐จ๐ง๐ฌ โ
Once youโve established that there is an objective problem with the code, it becomes clear that you should discuss it with your colleague.
The best way to do it is by asking questions and showing your colleague the respect you would want if the situation were reversed.
Asking questions gives the developer the opportunity to self-identify their errors and teaches them the queries they constantly need to ask themselves while writing their code each day.
4๏ธโฃ ๐๐ฒ ๐ต๐๐บ๐ฏ๐น๐ฒ
Be humble when you ask your questions:
๐ I donโt understand this section of code, could you explain it to me?
๐ Iโve always coded that in this way, what do you think of this method?
๐ Would it be better to structure the code like this?
5๏ธโฃ ๐๐ฑ๐๐ฐ๐ฎ๐๐ฒ
Youโre building a supportive work environmentโ .
So, be sure to avoid subjectivity, and give constructive, objective criticism to bad code.ย
6๏ธโฃ ๐๐ป๐ฐ๐ผ๐ฟ๐ฝ๐ผ๐ฟ๐ฎ๐๐ถ๐ป๐ด ๐๐๐ฎ๐ป๐ฑ๐ฎ๐ฟ๐ฑ ๐ฝ๐ฟ๐ฎ๐ฐ๐๐ถ๐ฐ๐ฒ
๐ Incorporate coding standards: a set of guidelines that lay out the styles and best practices that developers of each project need to follow.
๐ Code reviewsโ : Code reviews offer a great opportunity to suggest fixes or changes in a receptive environment.
7๏ธโฃ ๐ก๐ผ ๐บ๐ผ๐ฟ๐ฒ ๐ฏ๐ฎ๐ฑ ๐ฐ๐ผ๐ฑ๐ฒ
How do you tell a developer their code sucks? Short answer, you donโt.โ ๏ธ
Long answer, you educate, you learn, and you approach with an open mind. โ ๏ธ
๐ฝ๐๐ ๐๐ค๐๐ ๐๐๐ฅ๐ฅ๐๐ฃ๐จ โ ๐๐ช๐ฉ ๐ฎ๐ค๐ช ๐๐ค๐ฃโ๐ฉ ๐ฃ๐๐๐ ๐ฉ๐ค ๐๐๐๐ค๐ข๐ ๐ฉ๐๐ ๐๐๐ ๐๐ช๐ฎ ๐ฉ๐ค ๐๐๐๐ฉ ๐๐ฉ.