Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what is the difference between cascading and chaining [closed]

I just find from a forum about cascade. The question was what does cascading means in poo. I tried to find to google the answer, also tried to find some other stackoverflow threads about if but I couldn't. I just find this link http://en.wikipedia.org/wiki/Method_cascading

I know what is chaining, I used it, most in javascript, jquery and other languages, but I coundn't understand the difference between chaining and cascading. Can anybody help me? Or can anybody provide some useful links regarding to this?

like image 764
dan89 Avatar asked Dec 05 '13 22:12

dan89


1 Answers

Chaining is where you return the result of the method call to be used in the next call.

c#

Enumerable.Range(0,10).Skip(1).Aggregate(myList.First(),(result,listItem) => result += listItem));
//results in 45 being returned

Cascading can be implemented by using chaining when this is returned (making it sometimes tricky to differentiate between the two). jQuery does this.

jquery

$("#myId").css("background-color","blue").fadeIn().fadeOut();
//results in $("#myId") being returned
like image 57
Travis J Avatar answered Oct 05 '22 23:10

Travis J