Dwarves don't consider their exit paths when building things, or digging channels or the like. They're perfectly willing to build a wall while standing on the "wrong" side of it, or dig channels similarly. I've had to tear-down and re-build walls several times before they happen to get it right, and unfortunately don't have any ready option for doing the same with channels (assuming there isn't stone available to build a floor over the channel).
Knowing which side is the right side can be tricky, but generally I'd say that any of the following should be a clue that you're doing it wrong:
* With the barrier in place, the dwarf can no longer reach the outdoors (assuming they could originally)
* With the barrier in place, the dwarf cannot reach the point from which they accepted the job
* With the barrier in place, the dwarf cannot reach their bedroom
On a somewhat related note, dwarves don't really consider what they may be blocking off due to their build order. It is technically possible to build a channel down a one-tile-wide corridor, but if you just designate it all at once, odds are that you won't get most of it built; a dwarf will dig out one of the early spots and then no longer have a path to the later ones. At first glance I'm not certain it's possible to set yourself up so that building either one of two barriers prevents you from building the other, so it should be safe to say that if, having chosen to build square X of some designated area, square Y of the same connected area is no longer accessible (regardless of which side you stand on), then your build order is off. I say connected mainly to limit the scope of designations you have to look at, and since this issue will most often come up with channels and walls, both of which tend to be connected.