Local bike advocate Bryan McLellan says:
It is pretty important to choose one or the other and not weave between the two. Depending on the speed of an approaching car, they may assume you'll yield to them or not see you at all as you return to the travel lane.
I make a lot of judgment calls based on the configuration of the road. Since most roads do not have dedicated bicycle facilities, let alone ones that I feel safe in, you have to do this.
Remember that you have a right to the road (RCW 46.61.770) and bicycles do belong there. You are not required to use a shoulder, bike lane or alternate bike path if they do exist. You must only ride to the right side of the ride lane as you feel is safe (with exceptions).
Take a four lane road for example. I tend to ride toward the middle of the lane because cars often tend to squeeze past me in the lane when there is a car in the other lane rather than slowing and changing lanes. Four lane roads are often fast, making cars pass withing a foot or two very disconcerting.
If there is a shoulder that seems well swept (not covered in shards of broken glass or branches) and isn't laden with potholes, I'll prefer it even o a four-lane road, but definitely on a two lane road. If possible, take routes use non-arterial roads versus arterial roads without bicycle facilities. I ride down 6th Ave S in SODO instead of Airport Way S because while the later (except now during construction) tends to be nicer, there is a higher prevalence of issues with cars.
You can read McLellan's whole answer, or weigh in with some advice of your own, in Questionland!