I've been in application development for almost 10 years. I've been able to work on some very diverse projects in that time.
Most clients have very diverse environments.
I've also been very fortunate, surrounded by some highly skilled and motivated individuals. Although these are important factors, the real key is to carefully listen and identify the user's needs to provide the ideal solution for a given problem. So, the simple answer is, all the above. Having clearly defined and prioritized requirements and avoiding scope creep or last minute requests. Managing design trade-offs, finding the right balance between design and implementation.