It is much better, of course, when the fear of God helps one to avoid sinning in the first place. This proved true of David.
فَذَاتَ مَرَّةٍ ،‏ كَانَ شَاوُلُ وَثَلَاثَةُ آلَافِ جُنْدِيٍّ يُطَارِدُونَ دَاوُدَ .‏