Expected distribution of lambda sizes (Re: Syntax poll, take 2)

Llewellyn Falco isidore at setgame.com
Tue Jun 14 10:55:09 PDT 2011


> students.filter(s => s!=null && "Smith".equals(s.getName()))
Or
students.filter(s->s != null).filter(s-> "Smith".equals(s.getName());
[note: with lazy evaluation, this has simular efficiency]

But this is a fundamentally flawed conversation, because

"THERE IS NO JOE JAVA"

As a legacy code consultant, I might have a unique view on this, but
trust me, there is no such thing as the average java programmer.
there are even different level of things that might be thought of as average,
the average open source contributor
the average conference attending java programmer
but the VAST majority don't fall into either of those camps.
and while it might be all well and good to fight over which of the
following 5 lines of java code is better,
I constantly see classes with 20-40 thousand lines of code in
them.This will start crashing your IDE btw.  I have seen
"professional" development shops develop production code without
source control for 7 years. The level of programming out this is VAST
and ASTONISHING....



Conceptual Closures:

we have all seen code like

@#$#@%!#$
!@#$%%#@#$
!@#$
1@#$%
@#$
****************
****************
****************
@^$@#@
!@#%^^


Followed by code like
^#$%
@#$&&
&%$
****************
****************
****************
^&%^&%^$
#@%#$
@#$


and said "perhaps we should pull out that commonalty with a method
{
****************
****************
****************
}

many java programmer get this at some level (but again, I assure you
there are many who don't.... that's how you get a 40,000 line class)

Clousures help you when you encounter this scenario:

****************
****************
   ^&%^&%^$
   #@%#$
****************
****************
 followed by


****************
****************
  ^$#$%$#
  #$%$#%$%
****************
****************

as now you can make a method that takes the
() => {
  ^$#$%$#
  #$%$#%$%
}

Now, we can do this already with classes & interfaces, so why do we
need lambdas?
Because the overhead of a class is ~ 5 lines of code so we don't
remove the duplication when it's
that small, because it doesn't buy us anything.
Lambdas encourage us to remove that duplication properly.
So, as designers I believe we should focus on the 1-5 line lambdas, however,
there is no JOE JAVA, we will still see multipage long lambdas, I have
already seen them in legacy C# code, especially around threading

</rant>






-- 
Llewellyn Falco
www.approvaltests.com


More information about the lambda-dev mailing list