Have you ever been writing with a splotchy pen, and in the middle of your page, it suddenly leaked a glob of ink, making the whole page look messy and ruined?
In David's life, the page opens with the shepherd boy's devoted heart to his Shepherd; it scrolls to the courageous heart that stands against giants for God's honor; there is a perfectly scrolled stretch of a surrendered heart that doesn't take revenge, followed by a passionate heart for God's presence to be with him in Jerusalem.
David has made a mess on the page of his life--and he did it not in youthful ignorance, but when he was in his stride following God. Somehow, that makes the dark spot look messier and splotchier.
David's repentance and broken heart are evident. And when Solomon (the second son by Bathsheba) is born, "the Lord loved him; and because the Lord loved him, he sent word through Nathan the prophet to name him Jedidiah." (12:25)
The Promise came FIRST.
God wasn't caught off-guard, scrambling for a way to incorporate Solomon into His plan so that he could make David feel that he was forgiven. God already had the dark splotch as an integral part of the Big Picture HE was working--before the splotch was ever on the page.
I've noticed that believers often feel more forgiven for sins they committed before trusting in Jesus. There is a false perception that Jesus covers the sins up to repentance, but that I am responsible to keep the page clean from then on. (Note: this isn't meant to imply that we aren't called to holy living!)
I've also noticed that believers who have many dark splotches on the life-page before coming to Jesus, somehow feel that God's purpose for them starts at the point of repentance, and the past is an unfortunate mess that He has to step over to get to His Real Plan for them.
Our disappointment with ourselves and regrets from the past not only fuel the accusations of the Enemy to discourage us, they also keep us stuck thinking that an irretrievable clean page means it is a wasted part of the story.
The truth is, only a God who is both Sovereign and Compassionate can say to a broken-hearted child of His, "I already knew and had it incorporated from the beginning."