Jacek Laskowski (37) [Avatar] Offline

On page 62 in the Note "What's a Fluent Interface?" there's this sentence:

> the returned KStream object is a new instance

Why? Is this (going to be) explained in this book? What would happen if it the same instance were returned?

BTW I also think the fluent API in the note is not consistent as firstName method does not have with prefix as the others.

Bill Bejeck (47) [Avatar] Offline
Hi Jacek,

Thanks for the question!

The KStream fluent API returns a new instance each time because you are building a topology of processing nodes. So you can't return the same instance each time as you need different nodes to perform distinct actions.

With the Processor API it is more obvious as you manually create each node in the topology.

I'll review the chapter to make sure I explain why a new instance is returned each time.