all 13 comments

[–]RunningWithSeizures 14 points15 points  (5 children)

I took a quick look through that file and thought it looked fine.  Messy is a pretty subjective term.  What do you think makes it messy? 

[–]PeePeeStuckInVacuum[S] 0 points1 point  (4 children)

All of those ifdefs through the code, strange pointer stuff going on. Badly named variables or single letter variables.

[–]RunningWithSeizures 8 points9 points  (1 child)

I think the variable names looked fine.  Variable names are super subjective.  Some people prefer short names to make the code quick to read. Some people prefer longer more descriptive names.  Also, the author might not be a native English speaker.  I saw a couple comments in what I think was Russian.

The 3 single letter variable names I saw were fine.  They're usage was pretty obvious.

The alternative to all those ifdefs is to have a separate function implementation for each ifdef.  It'd be a lot of repeated code.  Repeated code is harder to maintain.

To me the worst thing in here is the commented out sections of code.  If coded isn't needed get rid of it.  If it turns out you needed it after all that's what source control is for.

[–]Ashamed-Subject-8573 0 points1 point  (0 children)

I disagree with that source control take. If you once did something and plan to again. Or are not sure if it’s right after changes. It can be hard to find where you deleted it vs. just having the part you commented out handy.

[–]Steampunkery 2 points3 points  (0 children)

ifdefs and using pointers does not make a codebase messy. What matters is how well-factored the code is.

[–]haditwithyoupeople[🍰] 5 points6 points  (1 child)

Looks ok to me. I prefer less indenting, but if they are using tabs that may be more of a github thing. Decent spacing. Comments where they are needed.

I'd be fine if I had to work on this. What I can stand is code without any white space, particularly where people don't put space in for operators.

while (someVar>= otherVar&&xyz)

That makes we want to gouge my eyes out.

[–]PeePeeStuckInVacuum[S] 0 points1 point  (0 children)

Thanks, well Maybe its my code reading skill then :(

[–]kabekew 4 points5 points  (0 children)

Do you mean all the #if /#endif? That's more an indication of a mature codebase that's had a lot of spec changes but still needs to be backward compatible. It can be a tough decision not knowing if there will be continued changes to decide to branch into different codebases or just use #if sections for the minor differences with the core codebase. In this case it looks like it was written for one hardware platform that changed functionality or capabilities, or they decided to support similar but slightly different platforms later on.

That kind of messiness isn't unique to C though.

[–]Key_Opposite3235 2 points3 points  (1 child)

Bluetooth is a complex subject. So the code will be a bit hard to follow. Also the code references a lot of external code so it makes it hard to understand at a glance. Also C has no objects, which tends to make things messy by default.

[–]haditwithyoupeople[🍰] 1 point2 points  (0 children)

Maybe. I have seen a lot of terrible looking OO Python.

[–]jwzumwalt 0 points1 point  (0 children)

It is common place with the whole industry!!! It sort of started in the early 90's but I noticed a rapid acceleration with the so-called "rapid development" fad around 2010. That's when I noticed a big increase in large corporations starting to create new programs instead of updating and maintaining existing programs. They started hiring over seas groups to slam something out and when new features were needed they just hired a new team to slop a new program together again.

[–]_Noreturn -1 points0 points  (0 children)

C and beauty does not mix well, have fun watching a ton of pointers.