Comments by "Winnetou17" (@Winnetou17) on "Low Level" channel.

  1. 5
  2. 5
  3. 4
  4. 3
  5. 2
  6. 2
  7. 1
  8. 1
  9. My several cents, that I haven't seen on other commenters: - asks for unsigned ints but reads them as %hi instead of %hu . But this is a very minor thing, I agree - I don't know for the life of me the requirement to enter the types in order. You can handle all cases TRIVIALLY by simply having something like switch(ptr->type) { case 124: // nobreak or whatever signal you have for your compiler to not see this as a mistake case 142: // nobreak or whatever signal you have for your compiler to not see this as a mistake case 214: // nobreak or whatever signal you have for your compiler to not see this as a mistake case 241: // nobreak or whatever signal you have for your compiler to not see this as a mistake case 412: // nobreak or whatever signal you have for your compiler to not see this as a mistake case 421: arrayCreation(0, 52, 62, 92, ptr); break; } - the example above was the most complex. When there's only two "types" chosen, there's only two cases (12 and 21 or 24 and 42 etc). - while writing the above, I just observed that the "124" case is missing. tsk tsk tsk, -1 point! - I think the main idea for most tips presented here is missing: the whole code I'd say is quite ok and readable and maintainable. Because it's small. When you get into a project with hundred of source files and thousands of lines of code and hundreds to thousands of functions, THEN having comments is important. When you have those "magic" numbers spread in 20 files, THEN you'll be doomed if you have to update them, so using a define for it is better, so it can be trivially updated - especially since it's a small program, I don't like the idea with the enum and the extra parsing, at least not being given as a blanket statement. That's basically overengineering. Feature creep. You're creating extra code, including RUNTIME code (which is why I dislike it) for a POTENTIAL FUTURE. You're making the code more complex and which runs slower just because "it feels right". There should be disclaimers. Like, do you know with decent certainty that this will not be updated (like getting that 5th type) ? If yes, then the current code is perfect. If you know it will be updated, or if you're not sure, THEN, maybe, think of a more extendible solution. Still, it's it's something small, it might still be ok to make it like that and only refactor it when it's needed. Don't fear refactorings, since you cannot avoid them. Instead embrace them and get used to them.
    1
  10. 1
  11. 1