nus-cs2103-AY2021S1 / forum

20 stars 2 forks source link

Difference between coding standard/coding style/coding quality? #490

Closed richardcom closed 3 years ago

richardcom commented 3 years ago

Hi! When I reviewed some of the questions in quiz, I got a little confused. Some questions emphasize on coding standard, some emphasize on coding style and some focus on coding quality. I wonder what are the major differences between them.

For example, I think that defensive programming and SLAP improves code quality but it may not affect coding style or standard. Then what about magic numbers, does it violates the coding style or standard?

Also I wonder what abt using the default branch, avoiding empty catch blocks etc. Thank you very much!

image

wltan commented 3 years ago

My understanding is that code quality entails a number of guidelines, one of which includes coding style. From the textbook:

Among various dimensions of code quality, such as run-time efficiency, security, and robustness, one of the most important is understandability.

Adherence to a coding standard is listed under code quality as well. https://nus-cs2103-ay2021s1.github.io/website/se-book-adapted/chapters/codeQuality.html#introduction-3

So informally, (enforcing a) coding style is part of code quality, but not vice versa.

damithc commented 3 years ago

My understanding is that code quality entails a number of guidelines, one of which includes coding style. From the textbook:

Among various dimensions of code quality, such as run-time efficiency, security, and robustness, one of the most important is understandability.

Adherence to a coding standard is listed under code quality as well. https://nus-cs2103-ay2021s1.github.io/website/se-book-adapted/chapters/codeQuality.html#introduction-3

So informally, (enforcing a) coding style is part of code quality, but not vice versa.

That's correct. Thanks @wltan 👍

richardcom commented 3 years ago

Thank you so much @damithc and @wltan ! May I please double check, so for using the default branch and avoiding empty catch blocks, based on the above explanation, then I think they shall belong to both coding style and code quality. Please correct me if I am wrong haha. : )

damithc commented 3 years ago

May I please double check, so for using the default branch and avoiding empty catch blocks, based on the above explanation, then I think they shall belong to both coding style and code quality. Please correct me if I am wrong haha. : )

Yes. To be clear, it is part of our coding standard/style. Someone else' style guide might not have it.

richardcom commented 3 years ago

May I please double check, so for using the default branch and avoiding empty catch blocks, based on the above explanation, then I think they shall belong to both coding style and code quality. Please correct me if I am wrong haha. : )

Yes. To be clear, it is part of our coding standard/style. Someone else' style guide might not have it.

Thank you so much for your detailed explanation Prof Damith @damithc : )