Return to site

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?

ยท coding,team

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. โš ๏ธ



๐˜ฝ๐™–๐™™ ๐™˜๐™ค๐™™๐™š ๐™๐™–๐™ฅ๐™ฅ๐™š๐™ฃ๐™จ โ€“ ๐™—๐™ช๐™ฉ ๐™ฎ๐™ค๐™ช ๐™™๐™ค๐™ฃโ€™๐™ฉ ๐™ฃ๐™š๐™š๐™™ ๐™ฉ๐™ค ๐™—๐™š๐™˜๐™ค๐™ข๐™š ๐™ฉ๐™๐™š ๐™—๐™–๐™™ ๐™œ๐™ช๐™ฎ ๐™ฉ๐™ค ๐™—๐™š๐™–๐™ฉ ๐™ž๐™ฉ.