Method Chaining Explained (in Computer Programming)
It is common to see the 'method chaining' syntax in source code all across the world and in almost every object oriented programming language. Also called 'named parameter idiom', it looks like a chain of methods being called one after another, hence the name 'method chaining'. It works because the methods that are being called on the object are actually returning the SAME instance of that object, meaning another method of that object can be called right after it nice and easily. In this video I show you an example of how you can implement method chaining in Java by creating a new class that supports it. The class is a simple number wrapper with an addition and print method. For your reference: https://en.wikipedia.org/wiki/Method_chaining If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!
It is common to see the 'method chaining' syntax in source code all across the world and in almost every object oriented programming language. Also called 'named parameter idiom', it looks like a chain of methods being called one after another, hence the name 'method chaining'. It works because the methods that are being called on the object are actually returning the SAME instance of that object, meaning another method of that object can be called right after it nice and easily. In this video I show you an example of how you can implement method chaining in Java by creating a new class that supports it. The class is a simple number wrapper with an addition and print method. For your reference: https://en.wikipedia.org/wiki/Method_chaining If this video helped you out and you'd like to see more, make sure to leave a like and subscribe to dcode!