fluent-interface

JQuery Taconite C# helper

I'm writing a helper class to wrap the functionality of JQuery Taconite plugin. The plugin enables you to process multiple DOM updates in a single Ajax call. The class simply enables you to construct the appropriate xml structure that is sent back to the client. I'm trying to wrap this functionality in a fluent interface. The basic exam...

Fluently setting C# properties and chaining methods

I'm using .NET 3.5. We have some complex third-party classes which are automatically generated and out of my control, but which we must work with for testing purposes. I see my team doing a lot of deeply-nested property getting/setting in our test code, and it's getting pretty cumbersome. To remedy the problem, I'd like to make a fluent...

Fluent interface design and code smell

public class StepClause { public NamedStepClause Action1() {} public NamedStepClause Action2() {} } public class NamedStepClause : StepClause { public StepClause Step(string name) {} } Basically, I want to be able to do something like this: var workflow = new Workflow().Configure() .Action1() .Step("abc").Action2...

method names with fluent interface

I have a Permissions class in Java with methods in fluent style like this: somePermissions.setRead(true).setWrite(false).setExecute(true) The question is, whether I should name these methods set{Property} or only {property}. The latter would look like this: somePermissions.read(true).write(false).execute(true) If I look at these me...

Do fluent interfaces significantly impact runtime performance of a .NET application?

I'm currently occupying myself with implementing a fluent interface for an existing technology, which would allow code similar to the following snippet: using (var directory = Open.Directory(@"path\to\some\directory")) { using (var file = Open.File("foobar.html").In(directory)) { // ... } } In order to implement su...

Register an Interceptor with Castle Fluent Interface

I am trying to implement nhibernate transaction handling through Interceptors and couldn’t figure out how to register the interface through fluent mechanism. I see a Component.For<ServicesInterceptor>().Interceptors but not sure how to use it. Can someone help me out? This example seemed a little complex. ...

Detecting end of method chain in PHP?

Hello! I cannot find a simple example about my question above: how can i detect the end of a method chain? I'm just looked Zend_Db_Select for example but this one is too complex for this simple question i think. Is it possible to catch the 'end' of a method chain in PHP? thanks, fabrik ...

Designing a fluent Javascript interface to abstract away the asynchronous nature of AJAX

How would I design an API to hide the asynchronous nature of AJAX and HTTP requests, or basically delay it to provide a fluent interface. To show an example from Twitter's new Anywhere API: // get @ded's first 20 statuses, filter only the tweets that // mention photography, and render each into an HTML element T.User.find('ded').timelin...

Partial generic type inference possible in C#?

I am working on rewriting my fluent interface for my IoC class library, and when I refactored some code in order to share some common functionality through a base class, I hit upon a snag. Note: This is something I want to do, not something I have to do. If I have to make do with a different syntax, I will, but if anyone has an idea on ...

how do closures help in creating a DSL/fluent interface: PHP examples?

Can you give me an example, in PHP, that shows how closures are helpful in creating a DSL (fluent interface)? edit: The accepted answer in the following question tells about nested closures. If someone could translate that example to PHP that would be helpful too: http://stackoverflow.com/questions/1966515/experience-with-fluent-interf...

How to make Spring accept fluent (non-void) setters?

Hi, I have an API which I am turning into an internal DSL. As such, most methods in my PoJos return a reference to this so that I can chain methods together declaratively as such (syntactic sugar). myComponent .setID("MyId") .setProperty("One") .setProperty2("Two") .setAssociation(anotherComponent) .execute(); My ...

PHP OOP: Chainable objects?

Hi everybody, I have tried to find a good introduction on chainable OOP objects in PHP, but without any good result yet. How can something like this be done? $this->className->add('1','value'); $this->className->type('string'); $this->classname->doStuff(); Or even: $this->className->add('1','value')->type('string')->doStuff(); Tha...

New Styles in C#

Fluent APIs are very common these days. Lately, I'm finding them in almost every system I work with. Mostly, they enhance readability but sometimes they lock me in to inflexible specifications, making understanding the runtime behavior of the specification that they build almost impossible. Is there a consensus on how to create a good fl...

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...

What advantages does method chaining have over plain imperative method calls?

Look at this example code, from a Telerik MVC grid: <% Html.Telerik().Grid(Model.InstallerList) .Name("InstallerGrid") .DataKeys(key => key.Add(c => c.InstallerID)) .Columns(column => { column.Template(action => {%> <%= Html.ActionLink("Edit", "Edit", new{ id = action.InstallerID}) %> ...

Change view when selected ribbon tab item changes

I'm using Fluent ribbon in a MVVM application. For each tab item I associate a view and a view model (set a new DataContext). How can I change the view and the view model (DataContext) each time when the selected tab item is changed ? It would have been nice to have an event that fires each time a tab item is selected, like Microsoft Rib...

Can the "Fluent" UI ribbon controls co-exist with the new "Microsoft Ribbon for WPF"?

We have an app in progress/development using the Office Fluent UI ribbon control library. It seems that the new RTM release of the Microsoft Ribbon for WPF is going to be the standard for the Microsoft libraries (at least for the next month or so). Can we install the Microsoft Ribbon for WPF safely on our dev boxes and begin transitioni...

Best way to exclude object from search with Fluent NHibernate Search

I have a class with a boolean property. I want to exclude instance with a false value from search result. What is the best way to do that with Fluent NHibernate Search ? ...

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...

Effects of method chaining

I know the benefits of chaining within PHP but lets say we have this following situation $Mail = new MailClass("mail") ->SetFrom("X") ->SetTo("X") ->SetSubject("X") ->AddRecipient("X") ->AddRecipient("X") ->AddRecipient("X") ->AddRecipient("X") ->AddRecipient("X") -...