This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Mastering Corda: Blockchain for Java Developers and have Jamiel Sheikh on-line!
See this thread for details.
Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

Sybex CSG 11, Chapter 15, Unclear/Misleading statement

 
Greenhorn
Posts: 7
Angular Framework Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
While reading the book i stumbled upon the following line: (Chapter 15, E-Book-Paragraph 2268-2269)

Moving on to Consumer, let's take a look at the andThen() method, which runs two functional interfaces in sequence.
... (code example)...
Notice how the same parameter gets passed to both c1 and c2. This shows that the Consumer instances are run in sequence and are independent of each other. By contrast, the compose() method on Function chains functional interfaces. However, it passes along the output of one to the input of another.



This passage lets me as reader assume that "andThen()" called on Function works exactly like in Consumer, which neither would make sense (as the original return value of the Function would be lost) nor is true. As expected from naming it chains the operations, just the other way around then compose().

Example: (extendet from example within the Book)


I assume, that the last phrase of the paragraph

However, it passes along the output of one to the input of another.  

should point this behavior out.
May it would be more clear, when using following text:

Moving on to Consumer, let's take a look at the andThen() method, which runs two functional interfaces in sequence.
... (code example)...
Notice how the same parameter gets passed to both c1 and c2. This shows that the Consumer instances are run in sequence and are independent of each other. By contrast, the andThen() method on Function chains functional interfaces, As it passes along the output of one to the input of another. The Function's additional compose() method provides also chaining but in reverse order.



And know i ask myself why compose not just was named andBefore()?

Regards
Samuel Silver Moos
 
Ranch Foreman
Posts: 175
8
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have just completed the section and agree with your assessment.

While it doesn't make any false statements, it would add very little text to make perfectly clear that Function chaining with Function's .andThen() works similarly to .compose() and differently to Consumer's.
 
Samuel Silver Moos
Greenhorn
Posts: 7
Angular Framework Debian Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Jesse Silverman wrote:I have just completed the section and agree with your assessment.

While it doesn't make any false statements, it would add very little text to make perfectly clear that Function chaining with Function's .andThen() works similarly to .compose() and differently to Consumer's.


Thanks for the review.

I totally agree with you. The statement is not false at all, may i should have announced this more clear too . It's just that the current wording let space for quite bad assumptions.
 
What a stench! Central nervous system shutting down. Save yourself tiny ad!
the value of filler advertising in 2020
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic