53

I bet everyone here knows these two situations:

1. You have a bug, show the code to somebody else for debugging and the bug is gone, but as soon as you're alone again, it reappears.
2. Your program works fine, you want to show somebody what you accomplished and...
IndexOutOfBoundsException: The index was outside the bounds of the array.

Comments
  • 7
    I've had a lot of these come to me, when people have an issue but when they try to show me the issue it's non existent.

    But for the second one, don't use raw arrays, for the love of God, just don't.
  • 7
    Just do your goddamn unit-testing and the stress goes away.
    With proper unit-testing you won't see exceptions like ArrayIndexOutOfBounds in a loooooooooooooooooong time.

    Why?

    Because you identify the edge-cases on the way, thinking about your code-structure every damn second...
  • 2
    @BigBoo I don't know the exception for Lists so I just went with arrays for this rant ¯\_( ツ)_/¯
  • 1
    @TylerDDevRant Same issue with tests :)

    Tests fail → you show someone → They pass → someone goes away → they fail

    Tests pass → you show someone → they fail
  • 0
    @filthyranter Alright. But why do you even need to access the individual index? Feels unnecessary.
  • 1
    @BigBoo When your method accesses something that you fetch remotely and that remote thing doesn't always have the same amount of entries, for instance.
  • 0
    @filthyranter How can you not use a for each loop for that and how does the amount of elements have to do anything with it?
  • 0
    @filthyranter
    This can't be true.
    For each unit-test, you create your specific static conditions, run your code and check the result.
  • 0
    @TylerDDevRant Funky shit happens sometimes, even with tests :)
  • 0
    @kkdev this is me personified😂😂😂
  • 2
    So get this- my high school cs project- a 2d game written in c++ and a 2d library. It had over 5k lines and being my first project, i knew nothing about debugging and testing.
    So OF COURSE the game had bugs. 3 months i spent making it, only saw minor infractions. But the MOMENT I showed it to professor for evaluation, SHIT WON'T EVEN START, CRASHED 4 times and yadayadayada. Luckily professor knew my pain, and i passed. GOD i cringe at the thought of it
Add Comment