This is related to conventions used in C#.
I've got a method that has two parameters (X and Y coordinates). These coordinates represent the position at which a "tile" may reside. If a tile resides at these coordinates, the method returns its number. If no tile resides at these coordinates, I'm wondering how the method should behave.
I see three options:
- Use exceptions. I may raise an exception every time Method finds no tile. However, as this situation is not rare, this option is the worst one.
- Do it the old fashioned C++ way and return -1 if there is no tile.
- Make the tile number a reference parameter and change the return type of method to boolean to show whether there is a tile or not. But this seems a bit complicated to me.
So, what should I do?