I wish researchers would spend less time on code readability and more on
abstraction. These Mickey Mouse Club tests are great if our goal is testing
ability to implement "line of business requirements" very literally but say
nothing about how to model the interaction between two complex state
machines, or deal with problems involving

I personally hate on both ways to process a list of numbers because the
filters themselves are not composed in a functional style as first class
values. This naive functional coding is now a worst case O (n^m) algorithm
where m is the number of filter passes.

So, the code should be:

Var ListOfFilters = [number -> number > 5,
number -> isEven(number),
number -> number < 9,
number -> number * 2 > 15]
Var filters = foldl (Op.AndAlso, ListOfFilters)
Var result = numbers.asEnumerable().first (filters)

So, as is usual, there is always improvements to be made in abstract
thinking. Note that I replaced asStream () with asEnumerable because it is
semantically more correct... if a list is not a lazy structure, the
operator (first) is.

We didn't even cover in my small discussion how to transform the list into
a lazy stream or cursor, to support early termination of the list being
consumed, using a trick called Superfold.

But this is really low level content. If a teacher can't teach this right
he or she is somewhere between 11 to 48 years behind best practices.
On Aug 11, 2015 9:43 AM, "Russel Winder" <rus...@winder.org.uk> wrote:

> http://blog.agiledeveloper.com/2015/08/prefer-functional-style-over
> -imperative.html
>
> Venkat Subramaniam is a well-known person in the Java/Groovy/Scala
> -verse.
>
> --
> Russel.
>
> =============================================================================
> Dr Russel Winder      t: +44 20 7585 2200   voip:
> sip:russel.win...@ekiga.net
> 41 Buckmaster Road    m: +44 7770 465 077   xmpp: rus...@winder.org.uk
> London SW11 1EN, UK   w: www.russel.org.uk  skype: russel_winder
>
> --
> You received this message because you are subscribed to the Google Groups
> "PPIG Discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ppig-discuss+unsubscr...@googlegroups.com.
> To post to this group, send an email to ppig-discuss@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups "PPIG 
Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ppig-discuss+unsubscr...@googlegroups.com.
To post to this group, send an email to ppig-discuss@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to