• 0 Posts
  • 11 Comments
Joined 1 year ago
cake
Cake day: June 9th, 2023

help-circle

  • Code should absolutely speak for itself. But the occasional comment is still good to explain the ‘why’ of the code when the why isn’t very obvious, often due to a niche requirement. Also any time you have to break out a hack, that needs comments up the ass, what was the bug, what URL did you find the fix at, why does this hack work, etc etc. It’s very satisfying to go back and remove those hacks after they are no longer needed, often because the underlying technology fixed the bug that had to be hacked around.


  • BombOmOm@lemmy.worldtoProgrammer Humor@programming.devLife Hack
    link
    fedilink
    English
    arrow-up
    87
    arrow-down
    1
    ·
    5 months ago

    Assuming the accounting system this thing links with both does not protect from SQL injection attacks (many don’t, despite it being easy to protect against) and also has a table named “Bills” with a field named “amount”; what this would do is go through every single Bills record and half the value in the amount field. This would completely fuck the system, particularly when it came to billing and tax filing as the numbers for accounts billing and receivable wouldn’t even come close to matching each other. The accounting department would have a hell of a time fixing the damage.


  • Since the health is a float, yeah, it can create issues. A health of 0.000000001 is greater than zero, but that would almost assuredly be displayed to the user as simply 0, causing player confusion. The easiest solution is to have health and damage always be integers. A less great solution is to use a non-floating point decimal format. If such doesn’t exist in your language, you can emulate one by having health and damage both always be integers, but move the decimal point over, say two points, when displaying to the user.


  • I’m still annoyed with how verbose Objective-C is. Just check out what one has to do to create and concatenate a string. Madness:

        NSString * test = [[NSString alloc] initWithString:@"This is a test string."];
        NSString * test2 = [test stringByAppendingString:@" This value is appended."];
    

    And god forbid you want to concatenate two things to a string:

        NSString * test3 = [test1 stringByAppendingString:[test2 stringByAppendingString:@" Adding a third value."]];