The final chapters of 2 Samuel form a coda (a concluding section). This section brings together and summarizes the main themes from earlier chapters.
These chapters are thematic, not chronological (arranged by topic, not by time). Because of this, not all the events happened at the end of David’s reign (for example, 2 Samuel 22:1).
The material is arranged using a common Hebrew literary pattern called a chiasm (a mirror-like structure). In a chiasm, the first and last sections match, and the middle section is the focus.
The structure of this chiasm is as follows:
A: Saul’s sin against the Gibeonites and the punishment that affected the whole community (2 Samuel 21:1–14)
B: David’s warriors and their heroic deeds (2 Samuel 21:15–22)
C: David’s Psalm (2 Samuel 22:1–51)
C′: David’s Psalm (2 Samuel 23:1–7)
B′: David’s warriors and their heroic deeds (2 Samuel 23:8–39)
A′: David’s sin involving the census and the punishment that affected the whole community (2 Samuel 24:1–25)
A chiasm draws attention to the center section. Here, the center is David’s hymns. These hymns do not focus on David himself. Instead, they focus on David’s God.