4 ms·
Actually I experienced worse restrictions when I was at Siemens writing embedded. Expanding on your list, here are some extras: - ternary operator("?") was str
by unnouinceput 6y ago
Actually I experienced worse restrictions when I was at Siemens writing embedded. Expanding on your list, here are some extras:
- ternary operator("?") was strictly forbidden. One had to use full "if () {..}else {..}" syntax with comments inside each branch even if the branch was empty
- a dynamic array written in an abstract way, when used and implemented specifically for current project had to become a constant static one, with values precalculated and copy/pasted to current project source. This was a fun one to do maintenance work years later.
- magic numbers inside code was forbidden. All numbers had to be defined in a specific header, with explanation why is that number said value.
- no variable parameters. All functions to have fixed parameters
- use of macros as minimum as possible. Code review was wasted sometime on 50% time over use of macros that were not already "classic" from the project point of view
- operator overload strictly forbidden. Also overloading functions was forbidden too.
- gpanders 6y agoAll of these except for the first two seem like good rules in general. Was the ban on the ternary operator just a style/readability thing?
- unnouinceput 6y agoMaintenance reasons. Future juniors to not have problems diving into projects directly. Chaining several ternary operators in same line is great to showoff your C prowess but a PITA to decipher what was doing, hence the rules.