Code Smells and How to Improve Them
In this section, we’ll look at many of the code smells found in C code. We’ll also envision some design changes that can make the situation better. As I mentioned, Fowler has a list of code smells, but his list is more suitable for the smells found in code written in an object-oriented programming language. Some apply to C, but then C also has its own common smells.
Duplicate Code
Duplicate code is essentially the root cause of most code smells. The problems of duplication are well known and were discussed earlier in DRY: Don’t Repeat Yourself .
Bad Names
Good names make code easier to understand; bad names make code obscure. Sometimes you’d think there is a penalty for using vowels or whole words ...
Get Test Driven Development for Embedded C now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.