The answer to this question should actually depend on the domain the solution is implemented for.
If you happen to simulate a physical search in a physical haystack, you might have the classes
- Space
- Straw
- Needle
- Seeker
Space
knows which objects are located at which coordinates
implements the laws of nature (converts energy, detects collisions, etc.)
Needle, Straw
are located in Space
react to forces
Seeker
interacts with space:
moves hand, applies magnetic field, burns hay, applies x-rays, looks for needle...
Thus seeker.find(needle, space)
or seeker.find(needle, space, strategy)
The haystack just happens to be in the space where you are looking for the needle. When you abstract away space as a kind of virtual machine (think of: the matrix) you could get the above with haystack instead of space (solution 3/3b):
seeker.find(needle, haystack)
or seeker.find(needle, haystack, strategy)
But the matrix was the Domain, which should only be replaced by haystack, if your needle couldn't be anywhere else.
And then again, it was just an anology. Interestingly this opens the mind for totally new directions:
1. Why did you loose the needle in the first place? Can you change the process, so you wouldn't loose it?
2. Do you have to find the lost needle or can you simply get another one and forget about the first? (Then it would be nice, if the needle dissolved after a while)
3. If you loose your needles regularly and you need to find them again then you might want to
make needles that are able to find themselves, e.g. they regularly ask themselves: Am I lost? If the answer is yes, they send their GPS-calculated position to somebody or start beeping or whatever:
needle.find(space)
or needle.find(haystack)
(solution 1)
install a haystack with a camera on each straw, afterwards you can ask the haystack hive mind if it saw the needle lately:
haystack.find(needle) (solution 2)
attach RFID tags to your needles, so you can easily triangulate them
That all just to say that in your implementation you made the needle and the haystack and most of the time the matrix on some kind of level.
So decide according to your domain:
- Is it the purpose of the haystack to contain needles? Then go for solution 2.
- Is it natural that the needle gets lost just anywhere? Then go for solution 1.
- Does the needle get lost in the haystack by accident? Then go for solution 3. (or consider another recovering strategy)