method-chaining

Chaining Extension methods in C#

Is it possible to create an extension method that returns the instance that is invoking the extension method? I would like to have an extension method for anything that inherits from ICollection<T>, returns the object. Much like how jQuery always returns the jquery object. public static object AddItem<T>(this ICollection<T> collection...

How to build multi oop functions in PHP5

I have a question about OOP in PHP5. I have seen more and more code written like this: $object->function()->first(array('str','str','str'))->second(array(1,2,3,4,5)); But I don't know how to create this method. I hope somebody can help me here, :0) thanks a lot. ...

Is jQuery method chaining an example of fluent programming?

I'm somewhat new to JavaScript/jQuery, but when I saw examples of method chaining it struck me as instantly familiar. Other interfaces like LINQ do something similar where the return type of a set of methods is the same as the type they operate on (TweetSharp does something very similar). Is this an example of fluent programming? Much...

Ruby - chaining methods and returning array

I have some methods for a class which return arrays like ["1", "3", "2", "6", "2"]. It is ok that these are string arrays, not numeric. I have another method that takes an array, and turns it into a single string like this 1 3 2 6 2. class Turn def initialize @rolls = 1 @dice = [] end def roll @roll = [] x = 5 - @dice.le...

Chaining asynchronous methods in JavaScript

Hello, I'd like to do something like this: var res = myAjax.post(); myAjax is basically my own ajax wrapper (asynchroneous). I don't necessary need the chaining, but i'd like to be able to do the call like shown above. I'd like a callback to be handled by the object itself. I've read about asynchroneous method queues, but, honestly, ...

What would be considered good examples of implementing the builder pattern when used in the development of a GUI?

Hi Coders, I am a complete newbie when it comes to the use of factory classes and methods, patterns, etc - in fact I first learned of them here on Stackoverflow when browsing Java related questions :-) In response to a previous question of mine it was suggested that I look into the use of the Builder Pattern in the development of my GU...

Silverlight Async Method Chaining (Possible gotchas?)

I am working on a 'proof of concept' Silverlight 4 project and am learning the way of THE ASYNC. I have stopped fighting the urge to implement some pseudo-synchronous smoke and mirrors technique. I am going to learn to stop worrying and love THE ASYNC. Most of the time I just use a BusyIndicator while async methods are running and all...

Test doubles (mocks/stubs) against method chaining or fluent interface syntax

I have code under test that basically looks like this (the specific code isn't important to the question. It is just here for explanatory purposes): public ICollection<Product> GetByCategory(string category, ISession session) { return session .CreateCriteria(typeof(Product)) .Add(Restrictions.Eq("Category", category...

How to make this in php?

Possible Duplicate: How to build multi oop functions in PHP5 Hey, I've seen this kind of code in a couple of forum systems but I can't find any examples like this: $this->function()->anotherfunction(); You can see a similar example in PDO: $pdo->query($sqlQuery)->fetch(); I don't know how this type of coding is called i...

PHP method chaining?

Hi, I am using PHP5, and heard of a new featured in object-oriented approach, called method chaining. Does any one know what it is? I want to know how to implement method chaining using PHP5 with object-oriented approach. Thanks ...

Chaining in Javascript without setting state

I like jQuery's ability to method chain commands ( .animate().css() etc ) which in the backend is achieved by returning the special variable "this". How can I implement a similar method of chaining without having to set state within my object. Take for example: that.getHospitalCoverDataStore().findBy('short_name').withValue('sam'); T...

Does chaining in jQuery work with manipulation and effect methods?

I'm trying to do the following method chain: $(somehtml).insertAfter("#someelement").fadeIn('slow'); What I would like to happen is for the somehtml to be added but with the fadeIn effect. However, this is not happening at all in my browser, it's just adding the contents as if the fadeIn wasn't even there. Am I doing the chaining in...