I am always a little comforted to find that sometimes even scholars don't know what to do with certain passages of Scripture. Such it seems is the case with the somewhat uncomfortable account recorded in Genesis 38. In one particular school assignment, I came across a number of commentators who deemed these accounts disjointed, calling Judah’s interlude with Tamar a “completely independent unit,” that bears “no connection with the drama of Joseph, which it interrupts at the conclusion of Act I.” But is that all there is to it?
A careful sequencing reveals a thematically cohesive narrative both poignant and instructive. As parallels emerge, the passages culminate in twin incidents of deceiver on the one hand, and actors unmasked on the other. Every denouement revealed a shocked and erring soul. Here in this chapter we see the flashpoint of redemption as Judah, Tamar, and Jacob's quarreling sons would one day show (Matthew 1:3; Revelation 21:12. For the purpose of overview, the following chart, adapted from The Art of Biblical Narrative, has been provided below.
 Genesis, The Anchor Bible (New York, 1964), 299.
 For greater study, I highly recommend Robert Alter’s excellent book, The Art of Biblical Narrative.