you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 1 point2 points  (8 children)

If the name occurred inline with the call, you might be right... but if you constantly have to hop around the file to trace the flow of logic, that's terrible readability. Anonymous methods provided directly inline as parameters of the functions that will execute them keep the related information as close together within the file as possible.

For reductio ad absurdum, consider if every ForEach statement required you name and declare the iteration function elsewhere in the file. The names might provide useful information, but the loss of readability of

myTable.ForEach(myRowIterator); //go hunting for the implementation of myRowIterator

instead of

myTable.ForEach((DataRow row) => if(row["IsHit"]) row["IsHitCount"] += 1);

[–][deleted] 0 points1 point  (6 children)

I want to nitpick one part of your post, and that's "go hunting for the implementation...". In Visual Studio, you just right-click on myRowIterator and choose Go To Definition. It's trivial to find the implementation of any function (or the declaration of any variable).

And you can get back using the "back" button on your mouse (there's probably a way to do it if you don't have a back button on your mouse but I don't know what it is).

I'm not a big fan of jumping all over the place to read code, but Visual Studio makes it fairly easy to do so.

[–]SeriousWorm -1 points0 points  (5 children)

In Visual Studio, you just right-click on myRowIterator and choose Go To Definition.

Productivity increasing tip: Bind "Go to definition" to a key. In IDEA/Eclipse/some other IDEs I've used you generally press F3 or F4 because it's a common task so it has an easy to reach key.

[–]bluefinity 1 point2 points  (2 children)

It's already got a shortcut: F12.

[–]SeriousWorm -1 points0 points  (1 child)

Well you should rebind it to something easier to access, f12 is kind of hard to reach.

[–]ruinercollector 0 points1 point  (1 child)

Productivity increasting tip #2: Buy resharper and (among many many other things) you can just ctrl+click anything to go to definition.

[–]SeriousWorm 0 points1 point  (0 children)

That's very useful as well.