The tag has no wiki summary.

learn more… | top users | synonyms

2
votes
1answer
75 views

For instance methods, would always returning self or this, instead of using a void return type, be a clean coding style? [on hold]

I just came across this article, and in particular, this answer. Essentially they're talking about returning self from instance methods to allow for method chaining. That being said, one of the ...
0
votes
0answers
47 views

Check some value between each function call

Can you recommend a nice way of checking a particular value between calls to a set of functions? E.g. something like this in Python (might not be terribly 'Pythonic'): self.error_code = 0 # this ...
4
votes
1answer
161 views

nodejs chaining with async

I'm trying to chain a series of methods that are async. I have heard of promises and futures but what I'm looking for is: obj.setup() .do_something() .do_another_thing() .end() and not: ...
3
votes
6answers
954 views

Coding style for chained function calls

A common thing you need to do is to take a value, do something with it by passing it to a function, and then do some more with the return value, in a chain. Whenever I run into this type of scenario, ...
13
votes
1answer
334 views

Are chained methods that require only one parameter per method equivalent to currying?

I've been toying around with Ruby lately and I found myself wondering if in pure object oriented languages (and even those that are not pure) making methods that take only one parameter and then get ...
32
votes
8answers
1k views

When using method chaining, do I reuse the object or create one?

When using method chaining like: var car = new Car().OfBrand(Brand.Ford).OfModel(12345).PaintedIn(Color.Silver).Create(); there may be two approaches: Reuse the same object, like this: public ...
10
votes
3answers
1k views

What is the pattern name for using method chaining to build an object?

I frequently use a pattern where I using method chaining to setup an object, similar to a Builder or Prototype pattern, but not creating new objects with each method call, instead modifying the ...