3 ms·
I work on a system where arbitrary property access results in database round-trips. So the following code: foreach(var b in a.Bs) { if(b.Data != null)
by Quarrelsome 9y ago
I work on a system where arbitrary property access results in database round-trips.
So the following code:
foreach(var b in a.Bs)
{
if(b.Data != null)
{
ThisIsInteresting(b);
}
}
results in a.Bs.Count + 1 round-trips to the server and then database if these fields have not been accessed before. (a.Bs is one and b.Data != null is one as well).
This is a fine example of what I'd call "unreadable" code because there is so much activity that is implied by actions that in other systems are completely innocent and well isolated.
Also there is the point of cognitive load. If your entire application was simply one function it is technically "readable" but the cognitive load of trying to work out what is in scope and what might change a given variable is too high to read without extraordinary effort.
When working in such systems (as I have before) you HAVE to rewrite it to even start reading it because a human memory cannot hold all that information at one time.
I think brushing it all of this off as "the reader isn't reading well enough" is disingenuous.