for example
drawline(int,int,int,int); // obscure
drawline(Point,Point); // clearer
this is only "clearer" until you find yourself at the very common case where you use several libraries where each defines its own "Point".Now you're writing something like
drawline(Point(vec.x1, vec.y1), Point(vec.x2, vec.y2))
Pretty ugly!And of course drawline(Point, Point) isn't clearer at all imo. What's the coordinate system? What are the units? Any performance notes on this function? Etc. I'll be checking the documentation the first time anyway.
void do_something(vector<string>& v)
{
string val;
cin>>val;
// ...
int index = 0; // bad
for(int i=0; i<v.size(); ++i)
if (v[i]==val) {
index = i;
break;
}
// ...
}
this is shown to be inferior to the find() version. Again, it's only inferior until the very common case where you're doing something else with the index, which is pretty common during debugging. Then you'll be rewriting the above "bad" version anyway.Similar problems other higher order functions like for_each().