fluent-interface

101 tutorial for setting up nhibernate?

I am looking for a tutorial on setting up nhibernate. There seems to be few out there, but most are either written in gibberish, or are on an extremely ancient release. Any good resources, possibly even the inclusion of fluent or a code configured install? ...

Is there any disadvantage to returning this instead of void?

Say instead of returning void a method you returned a reference to the class even if it didn't make any particular semantic sense. It seems to me like it would give you more options on how the methods are called, allowing you to use it in a fluent-interface-like style and I can't really think of any disadvantages since you don't have to...

How do I get access to Castle Windsor's Fluent Interfaces API?

I've been having tons of problems getting the non-xml configuration for Castle Windsor set up working properly. In the meantime I've seen more and more people giving advice via the Windsor Container fluent interface. I've been Gooogling about for the last day and I cannot find this API anywhere. I am talking about the key .Register() ...

Combine Fluent and XML mapping for NHibnernate

Hi, I just fell in love with NHibernate and the fluent interface. The latter enables very nice mappings with refactoring support (no more need for xml files). But nobody is perfect, so I am missing the many-to-any mapping in fluent. Does anybody know if it is already there? If so, a simple line of code would be nice. But to stick to t...

Fluent interfaces in C#

I have a question with fluent interfaces. We have some objects that are used as parameter objects for a SQL interface, here's an example: using (DatabaseCommand cmd = conn.CreateCommand( "SELECT A, B, C FROM tablename WHERE ID = :ID", SqlParameter.Int32(":ID", 1234))) { ... } For some of these parameters, I'd like to enab...

Tips for writing fluent interfaces in C# 3

I'm after some good tips for fluent interfaces in C#. I'm just learning about it myself but keen to hear what others think outside of the articles I am reading. In particular I'm after: when is fluent too much? are there any fluent patterns? what is in C# that makes fluent interfaces more fluent (e.g. extension methods) is a complex fl...

EBNF to fluent interface

I have recently had the need to write a fluent interface for C# that will essentially mirror SQL. Yes, I am aware of LINQ to SQL, but I'm interesting in getting "closer to the metal"--having something that essentially provides nothing more than an Intellisensified SQL shim within C#. E.g., var fq = new FluentQuery(); Expression<Action...

Fluent Interfaces - Method Chaining

Method chaining is the only way i know to build fluent interfaces. Here's an example in C#: John = new JohnBuilder().AddSmartCode("c#").WithfluentInterface("Please").ButHow("Dunno"); Assert.IsNotNull(john); [Test] public void Should_Assign_Due_Date_With_7DayTermsVia_Invoice_Builder() { DateTime now = DateTime.Now; ...

Is there a fluent assertion API for MSTest?

I've recently been exposed to the fluent interface in nUnit and I love it; however, I am using msTest. Does anyone know if there is a fluent interface that is either testing framework agnostic or for msTest? Thanks, Josh ...

Using return statements to great effect!

When I am making methods with return values, I usually try and set things up so that there is never a case when the method is called in such a way that it would have to return some default value. When I started I would often write methods that did something, and would either return what they did or, if they failed to do anything, would r...

Interesting uses of fluent interfaces?

I am wondering where and when fluent interfaces are a good idea, so I am looking for examples. So far I have found only 3 useful cases, e.g. Ruby's collections, like unique_words = File.read("words.txt").downcase.split.sort.uniq.length and Fest (Java) for unit testing: assertThat(yoda).isInstanceOf(Jedi.class) .isEqualTo(foundJed...

Fluent interfaces and leaky abstractions

What is a fluent interface? I can't find a good definition of this, but all I get are long code examples in a language I am not very familiar with (e.g. C++). Also, what is a leaky abstraction? Thanks ...

Castle-Windsor Fluent Interface: How to register all implementations of all interfaces?

I have two assemblies EDC2.DAL and EDC2 where EDC2.DaoInterfaces defines a bunch of interfaces for data access objects to objects in the EDC2.Domain namespace. These are all implemented by classes in EDC2.DAL. So to give an example: Assembly EDC2 Namespace EDC2.DaoInterfaces ICustomerDao IProductDao Assembly EDC2.DAL Name...

What conventions/idioms/patterns are you using configuring IOC Containers using the new Fluent Interfaces

I am in the middle of moving over a large body of code to Castle Trunk which includes the new fluent interface for configuring the container. Since the project has a huge windsorConfig xml file that is beyond maintainable, I thought I would start to take advantage of this new feature. I know other containers (e.g. StructureMap 2.0) also ...

Converting an XML document to fluent C#

I'd like to convert an external XML document without any XSD schema associated with it into a fluent .NET object. I have a simple XML file like: <application> <parameters> <param></param> <param></param> </parameters> <generation /> <entities> <entity ID="1"> <PropTest>Test</PropTest>...

Separate decode/encode interfaces or in one interface

I'm creating an implementation that performs conversion from one form to another. The design problem I am facing now is whether the Encoder and Decoder API should be in one interface or in separate ones. e.g. Apache MINA uses separate interfaces I am currently doing something like this: interface Convertor { A encode( B b ); ...

Castle Windsor: So what DOES ActAs do?

I noticed that the castle windsor fluent component registration interface has the rather confusing ActAs() method. Googling around for it the only reference I found was at their wiki here. TODO (Stuff that could be documented) what does ActAs() do? Not too helpful. The source doesn't seem to have any unit tests for the...

How to do a PHP nested class or nested methods?

How can I do this in PHP $myDBClass->users()->limit(5);//output you limited users to 5 $myDBClass->comments()->limit(3);//output you limited comments to 3 what I meant is nested methods or nested class (I don't know!) so when I call the limit method as a child of users it will know that I am calling it from "users" method -or class- ...

Should source code be the only software design documentation?

I just came across Jack Reeves' articles asking "What is Software Design." I think he makes excellent points and now wonder whether source code should stand as the only software design documentation we create and leave behind. I think this fits in well with the ideas of DDD's Ubiquitous Language and could easily become readable documenta...

What's the point of DSLs / fluent interfaces

I was recently watching a webcast about how to create a fluent DSL and I have to admit, I don't understand the reasons why one would use such an approach (at least for the given example). The webcast presented an image resizing class, that allows you to specify an input-image, resize it and save it to an output-file using the following ...