That’s when you have to watch out and resist the temptation to take code that works for code that’s good. What you’ve found on Stack Overflow is - in all but the rarest cases - not a solution but rather a clue. It can certainly make for a great pointer, but it was not written with your exact problem / requirements / constraints /code base / application in mind. And sometimes, it might simply be a dirty hack.
Embrace Stack Overflow as a good source of guidance for certain problems. But also take the time to thoroughly and honestly evaluate if you’ve found a real, solid solution.
Our Development Philosophy (1): Architecture, Design Patterns and Programming Principles (cache)
Pretty well stated by the Tower team. Stack Overflow makes you find leads faster, but the solution is up-to-you and that’s part of the beauty of that job :-).
Make sure to check out the second part too (cache), as writing code is only the first step of a long path.