Re:C-style: My favorite C programming practices
by amszmidt on Monday May 20, 2024 @02:28AM
(#40412874)
The one about not using 'switch' and instead using combined logical comparisons is terrible ... quite opinionated, but that is usually the case with these type of style guides.
[ Parent
| on HN ]
Re:C-style: My favorite C programming practices
by aulin on Monday May 20, 2024 @03:09AM
(#40413068)
it's like they purposely add some controversial rule just for engagement
Re:C-style: My favorite C programming practices
by ezconnect on Monday May 20, 2024 @03:28AM
(#40413165)
He even uses 'switch' on his code.
Re:C-style: My favorite C programming practices
by mcinglis on Monday May 20, 2024 @11:26AM
(#40416578)
As the author 10 years later, I agree. A hard-and-fast rule to ban switch, as that rule seems to advocate, is silly and terrible.
Switch has many valid uses. However, I also often see switch used in places where functional decomposition would've been much better (maintainable / testable / extensible). So I think there's still value in advocating for those switch alternatives, such as that rule's text covers. Not that I agree with everything there either. But, useful for discussion!