442 questions
2 votes
1 answer
76 views
Why does PHPUnit require an intermediate variable when mocking/stubbing?
I am doing some unit testing with PHP. I got stuck on an error that the fluent interface of PHPUnit requires an intermediate variable. What is the reason for this behavior? See MyTests::works vs. ...
1 vote
1 answer
108 views
How can I avoid declaring full generic parameters when storing a custom typed object, while keeping type safety at compile time?
I've created a small library called StreamX, which acts like a type-safe, index-aware zipper to enable parallel streaming over multiple lists. It supports functional operations like forEach, map, ...
0 votes
0 answers
36 views
Best practices for modifying collection inplace with LINQ
I have a collection with objects of different types, each of them inheriting from a class named Component. I then want to modify the collections by my needs nicely, with use of kind of declarative and ...
1 vote
0 answers
62 views
Declaring a variable of self-referencing generic type in C# 10.0
Good time of the day! I have a generic interface which has a self-reference: public interface IBuilder<TObject, TBuilder> where TBuilder : IBuilder<TObject, TBuilder> { public ...
0 votes
1 answer
70 views
Is it necessary to return the same object in methods with fluent interface
in some sources such as the original article of Martin Fowler aren't written that methods would return the same object, and methods in examples return different objects but in some sources(newer) such ...
1 vote
1 answer
117 views
The different between fluent interface and method cascading implemented by method chaining [duplicate]
When I read about it on Wikipedia, it seemed to me that these two are almost the same, but the same article says that they differ not only in the use of DSL. Note that a "fluent interface" ...
1 vote
2 answers
244 views
What's the difference between 'with command' and 'fluent interface' in Delphi?
Why should I use fluent interface in Delphi instead of using 'with command'? I heard about both, but I haven't found the difference. I'm trying to find the best one for my project. It seems to work ...
0 votes
3 answers
470 views
c# how to make a conditional method chaining in fluent interface?
I'm developing .NET core app that using selenium, so I've designed the logic using fluent interface that make the code more readable and maintained. I have a problem which is how to make a conditional ...
0 votes
1 answer
78 views
Fluent Builder Interface lets me set middle name and last name more than once
I'm implementing a Fluent Builder Interface and instead of having null, empty or whitespace checks, I force the developer to fill in the following mandatory fields: firstName, prefix and facultyNumber....
0 votes
0 answers
25 views
How to not expose the data structure in an object while accepting a collection of items with named parameters?
Most of the time, we can replace a fluent interface with named parameters. class Cart { fun withItems(vararg items: Item) = this } fun aCart(): Cart { TODO() } class Item fun anItem(): Item ...
0 votes
1 answer
68 views
How to terminate last function in chaining method php
I got some problem and I don't know how to fix it. this is sample for the problem class DancingClass { private static $associate = []; private static $first; public static function first($...
0 votes
1 answer
2k views
When to return 'this' instead of 'void' in a method and why? [duplicate]
What are the benefits (or drawbacks) of returning a reference to 'this' object in a method that modifies itself? When should returning a 'this' be used as apposed to void? When looking at an answer on ...
0 votes
1 answer
137 views
Double destructor call in C++
I'm trying to create an object-configurator using a fluent interface. Code: class Configurator { public: Configurator() { printf("Constructor.\n"); } ~Configurator() { ...
-1 votes
1 answer
117 views
Immediately calling destructor after setting in the fluent interface in C++ [closed]
I want to create a class only for setting params for function. I'm using a fluent interface for that. Some function returns the object to setting params and real code will execute in the destructor of ...
0 votes
2 answers
7k views
Instantiate a generic class T object and return it [duplicate]
I'm working on java selenium tests and I am trying to setup a fluent/method-chaining design code: I have a generic button class that allows navigating from a page class to the other. Buttons are ...