coding style - Readability of heavy function call nesting? -


I have often argued that heavy nested function calls should not be used because they are unreadable. However, instead of using the temporary variable, many unnecessary verbness is generated, and mentors the reader mentally linking each temporary variable that shows it. When Lisp code is usually formatted, it happened to me that the nested function call can actually be made quite readable if you format them to reflect nesting. For example:

  // Completely unreadable: auto-lineiter = filter! "A.length & gt; 0" (map! Bar (file (filename) .byLine ())) // // Fully readable. The only difference is the formatting. AutoLine = Filter! "A.length> 0" (map! Bar (file (filename). ByLine ())); // readable, but unnecessarily verbose: auto rawlines = file (file name) .byLine (); Auto snatch = map! Strip (raw lines); Auto filtered = filter! "A.length & gt; 0" (stripped);  

Write something like the first example in the nested function form, IMHO, is equivalent to doing the following in more procedural-style code:

 for  (i = 0; i & lt; 10; i ++) {for (j = 0; j and lt; 10; j ++) {if (x  

The real problem in both cases is poor formatting, not a nest hunt. How would you rate the readability / understanding of the temp variable version, along with the virtualization of a well-formatted nested function version? Do you think call nesting a heavy function is a bad style, even if it is formatted for maximum readability? If so, why?

You say "instead of using the temporary variable makes literally a lot of unnecessary and reader mentally Linking each temporary variable to mentally link "- But IMO is another way of saying that you have broken the thing into things that the reader can understand each other at a time - you have more Made readable.

I am very happy to add an additional variable to break a long line in different steps (in my example 3), but the important thing for me is that you can break this thing right < Strong> real is a good indicator of whether you can get a good variable name; If you can not do this, then maybe this is not a separate step which requires division.

There is nothing wrong with your example 2, but that is much more than that time and I will definitely break it, it comes to debugging, then you will thank yourself ...


Comments

Popular posts from this blog

sql - dynamically varied number of conditions in the 'where' statement using LINQ -

asp.net mvc - Dynamically Generated Ajax.BeginForm -

Debug on symbian -