Throwing crap together is not a good strategy.

Sometimes a programmer will play fast and loose and try random things to solve some kind of problem. Through various hacks, the system appears to start functioning. The problem is, the system could stop functioning later, or perform improperly under different conditions. Hacks are notoriously unreliable.
As a professional software engineer, you should refuse to hack code that only seems to work. Software should be deliberate, with obvious intent. One should write code that is clearly, obviously correct.
Write tests that will prove the software implementation is correct. When other programmers view the tests, they should easily understand the desired behavior of the system, including how it should perform in the edge cases and under awkward circumstances.
Save the hacking for things that don’t matter, like competitions and personal websites. Hacking can be fun and provide an opportunity to show off clever solutions, but it has no place in professional work.