C # - Name the Design Pattern

Using Fluent Interface design here

if i call something like

 dog.Train("Running").Train("Eating").Do("Running").Do("Eating"); 

      

What is the name of this template? is this a chain of responsibility or is there any specific project template name associated with it?

+2


a source to share


3 answers


Method chaining

EDIT:



From the wikipedia article :

a free interface (as originally conceived by Eric Evans and Martin Fowler) is a way to implement an object-oriented API in a way that provides more readable code.

A fluent interface is usually implemented using method chaining to relay the command context of a subsequent call (but a fluent interface entails more than just method chaining).

+4


a source


I don't know what this is really a "pattern". It's more of an idiom.



Anyway, I would call it either a free interface or an internal domain language.

+2


a source


The chain of responsibility is more of a multiple object class / level pattern, where messages are passed through an object hierarchy and each object can decide whether it can deal with a message or convey it.

I think the sample you are showing here is basically just "Fluent Interface" as you said.

+1


a source







All Articles