r/programminghorror • u/HeWhoShantNotBeNamed • 19h ago
C# Very readable and maintainable method
I wrote this several years ago. It does work.
7
u/Poiuytgfdsa 11h ago
If i saw a comment above a function that says “intelligently handles edge cases” with no specifics id get irritated
3
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” 11h ago
C# does let you use character literals, right? I think replacing all those ASCII codes with characters would help a ton.
Also, it looks like you are checking both before and after each character. Is that really necessary? Like couldn't you just after each character look ahead once. I think you could even say i < joinedString.length - 1.
1
u/MeLittleThing 2h ago
C# does let you use character literals, right?
yes, and there are methods in the
charstruct, such aschar.IsLetter(c),char.IsUpper(c)and so on
2
u/tom83 16h ago
Hit reformat and it will be readable. It's a pure function, so unit test can fully determine the behavior to the point that the impl is irrelevant.
1
u/HeWhoShantNotBeNamed 16h ago
Reformat? Lol that is with it "formatted" correctly according to ReSharper/Rider
2
1
28
u/russellvt 17h ago
That color scheme is horrendous, and looks like it lost a number of pixels from all the times it's been reposted or resaved or something.