We can imagine David understanding the laws of God well, having spent so much time developing his relationship with the Creator, who is always more ready to talk to us than we are to Him. David would see the practical applications of the Ten Commandments all around him.
Inspiration from Anne Elmer