Are there any recommendations for returning different types of returned data with overloaded methods? For example, if I have a Load method in my DAL, I either want to load a single element or a bunch of elements. I know that I can use several approaches:
Loading a single object
MyBusinessObject LoadOne(int id)
{
}
Loading multiple objects
MyBusinessObject[] LoadMany(params int[] ids)
{
}
Now I know what I can do is to overload one method and have different types of returned data. For example:
MyBusinessObject Load(int id)
{
}
and
MyBusinessObject[] Load(params int[] ids)
{
}
While it seems like nothing prevents me from doing this, and it keeps things clean from an API point of view, does this seem like a good idea? I stumbled upon it last night, and part of me thinks I should not do this because of the desire for matching return types for the overloaded method.
Load (int id), , . , , , , , , .
, , :
- .
- , , . API, , , .
- , .. , , , , , , , .
, , .
- , ? .