The only secret that is not known by young programmers is: programmers are not as smart as they think.
Once you know that, you stop writing code that you won't understand next month, you start to appreciate version control, you don't fix code that already works, you document your code, you don't interpret specification, you don't code features that might be useful someday in the future, you don't reject legacy code, ...
In other words, the secret is experience.