Skip to main content

Questions tagged [method-chaining]

8 votes
4 answers
1k views

In a recent PR, a developer, whom I will call Alice, came across a lot of resistance by a coworker (Bob) because she wrote a utility code unit in a fluent style rather than in a classical style. In ...
Daniele Repici's user avatar
22 votes
11 answers
5k views

In an object oriented language like Java or PHP (other perspectives welcome as well) if I use a fluent interface like this: my_pizza = (new Pizza).withTopping("pineapple"); another_pizza = ...
AndreKR's user avatar
  • 577
4 votes
1 answer
92 views

I have legacy code and it has a function called initialize and this function calls N amount of methods of same object and these methods are responsible for validating identity of personas. At each ...
jeffbRTC's user avatar
  • 167
0 votes
1 answer
94 views

I've got an Algorithm class whose responsibility is to find if a given word is in a list of words. As part of doing that, the algorithm first has to lowercase the words, remove punctuation, and ...
Andy Gondzer's user avatar
1 vote
4 answers
1k views

I'm becoming addicted to writing fluently (perhaps incorrectly originally said "declaratively") and I'm taking it to possibly unwise extremes, but the more I write this way the more one thing stands ...
Dave Cousineau's user avatar
1 vote
1 answer
3k views

I am working on a game, and I have many instances where I have to do something like this: Game.getInstance().getEnergyDropManager().getDrops() Or: this.dimensionSelector.selectDimension(Game....
MCMastery's user avatar
  • 173
3 votes
2 answers
2k views

Given this code from the Symfony framework: use Symfony\Component\HttpFoundation\Request; public function indexAction(Request $request) { $request->isXmlHttpRequest(); // is it an Ajax ...
bln_dev's user avatar
  • 189
7 votes
1 answer
5k views

I'm writing a C# style guide for my team and I'm trying to describe the benefits of side-effect-free functional-style methods. I want to include online references to back up the suggestions, but I can'...
Max's user avatar
  • 186
2 votes
1 answer
314 views

That question bothers me for years, so, imagine some code that in 99% looks like a non-sequential (order does not matter) list of some specific objects method calls - and those calls are independent ...
shabunc's user avatar
  • 2,464
0 votes
1 answer
207 views

Disclaimer: I am going to write in Python and in the context of web development with Django, but this question is not language nor framework specific. Let's say I have a PizzaManager class that ...
dabadaba's user avatar
  • 2,266
2 votes
2 answers
3k views

Just wondering if there is a good way to do this? Currently i'm performing the method calls as if they were happening prior to the conditional block, then comparing what would be the result in "[...
ldmccartin's user avatar
3 votes
0 answers
210 views

Given the following code snippet in a Laravel Controller: $this->userRepository->saveByProject( $this->fileRepository->saveByProject( $this->metricRepository->...
schellingerht's user avatar
3 votes
2 answers
1k views

Let's say I'd like to perform the following command: house.getFloor(0).getWall(WEST).getDoor().getDoorknob(); To avoid a NullPointerException, I'd have to do the following if: if (house != ...
q126y's user avatar
  • 1,733
7 votes
8 answers
2k views

return this (or similar construct) allows method chaining. Lack of it is painful, because you have to write such code (C#): var list = new List<string>(); list.Add("hello"); list.Add("world"); ...
greenoldman's user avatar
  • 1,533
3 votes
1 answer
232 views

I am learning about coding to an interface in OOP programming. I understand you should code to an interface so you can 'swap out' functionality. However, I have a situation where I feel I can reuse ...
myol's user avatar
  • 235

15 30 50 per page