Method Chaining is Awesome

Have you ever worked with classes that are thousands of lines long? Those classes end up encapsulating tens of related functionality, and you end up repeating that class' name hundreds of times. But not today. In this video, we will clean up some mess using method chaining.
Method chaining is an idiom in object-oriented languages where an object's methods return a reference to the object itself. This way, method calls can be chained together, without requiring variables to store the intermediate method call results. I find method chaining to be an excellent utility for classes with lots of small and relevant functionality. Objects encapsulating database queries, test code, and UI code are great examples of this. Method chaining can also be used to build a fluent interface or implement the builder pattern.
In this video, you will see several implementations of method chaining, along with some nice animations to help to understand its difference from regular method calls.
Outline of this video:
* Overview
* Inspiration for This Video
* Method Chaining
* Benefits and Drawbacks
* Conclusion
If you want to read more on the subject, here are some good Wiki articles to check out:
* en.wikipedia.org/wiki/Method_...
* en.wikipedia.org/wiki/Fluent_...
If you want to read or contribute, you can find this guide on:
* quanticdev.com/articles/metho...
My Software Engineering Playlist:
* • Software Engineering
- - - - - - - - - - -
/ quanticdev
/ quantic_dev
quanticdev.com

Пікірлер: 3