It's a great question that can be answered differently for and by different levels of players. In the traditional sense, there are fingering concepts that are pretty standard to the DB that it behooves everyone to learn. Different teachers have their own ways to get there, but they end up being largely built around the same basic concepts. Beyond these basics, the methods start to diverge. I'll detail three approaches below, all based on the notion that there are multiple ways to approach fingering most passages of music:
One way of looking at the issue ( mentioned earlier) takes string length into account as a primary component of fingering. The bass tends to sound fuller and more resonant when playing any given note on the longest possible string length, so from a "fullness of tone" point of view, this aspect is paramount. Classical bassists tend to finger from this perspective a lot to maximize the resonant sound they can pull from any passage. This explains why you see a lot of soloists shifting along the G string in lyrical passages so often.
Another way way of approaching the issue (also mentioned earlier) is ergonomics; which fingering is easiest to navigate for the left hand (here we are assuming that the right hand is up to the task)? As a component of that, what fingering minimizes shifting, thereby potentially minimizing possible intonation traps during performance? In this paradigm, it is often common to approach playing rangy passages across the strings as Damon mentions above. This is especially important for improvisers, since they are creating their lines on the fly and have little time to conceive of fingerings consciously in real time.
A third (and perhaps the most advanced) way of looking at the issue is in terms of the musical line itself: what fingering allows the line to speak as it was conceived musically, with the proper phrasing and articulation? A good example of this as a consideration would be any legato passage that has a descending 4th in it. A typical "bridge" fingering (i.e. 1-1, 2-2, 4-4) from the higher string to the lower tends to leave a small breath in the phrasing that is the result of the fingering not technically connecting the two sounds in an overlapping way, especially in pizzicato playing. In cases like this, I'll often use an unorthodox fingering to connect the two notes rather than leave a breath or break in the phrasing that the music doesn't really call for.
I think of this third way of phrasing as the highest/most advanced way of phrasing because it uses musical phrasing as the ultimate criteria for fingering choice, but have to remind students often that it is entirely dependent on the player having all options available to them technically at a high level. In other words, if you don't have the basic techniques down, it makes little sense to choose an advanced technique.