Object-oriented programming is a programming paradigm using "objects" – data structures consisting of data fields and methods together with their interactions – to design applications and computer programs. Programming techniques may include features such as data abstraction,...
. Each method returns an object (possibly the current object itself), allowing the calls to be chained together in a single statement. A method chain is also known as a train wreck due to an increasing amount of methods stacked after another in one line.
C#:
PHP:
Method chaining is not required. It only potentially improves readability and reduces the amount of source code. It is the core concept behind building a fluent interface
Fluent interface
In software engineering, a fluent interface is an implementation of an object oriented API that aims to provide for more readable code....
.
C#
C++
Java
Actionscript 3
The following is an example of a class with method chaining implemented in Actionscript
ActionScript
ActionScript is an object-oriented language originally developed by Macromedia Inc. . It is a dialect of ECMAScript , and is used primarily for the development of websites and software targeting the Adobe Flash Player platform, used on Web pages in the form of...