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
118
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
252
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
472
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
70
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
119
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 ...
1
vote
1
answer
418
views
Is it possible to deserialize a yaml document with setters that are not void?
I am working on a project that has a fair amount of data objects that use a "fluent interface" or "method chaining" on their setters so all of the setters in each data object return this. I have ...
0
votes
0
answers
94
views
C++ It is possible to use Fluent Interface inside Fluent Interface?
I want to achieve API to client to look like this: (modifying subcomponents by using fluent interface)
FluentMainComponent("|FluentMainComponent|")
.setA()
.SetText("fa2")...
2
votes
1
answer
1k
views
Implementing a One-to-Zero-or-One Relationship and a One-to-Many Relationship of the Same Class
I am having trouble mapping the following classes.
I want MainAboutPage to be optional (one-to-zero-or-one) and AboutSubPages is obviously one-to-many.
Ideally I want to keep the WebsiteId ...
0
votes
1
answer
57
views
This code was working but now I get a recurssion error from the counter in __getattribute__
I need help making my Query object not have a recursion error. To check the right amount of function have been chain-called I am adding a counter to get attribute that caused a recursion error. This ...
0
votes
0
answers
250
views
How to add potential owner for dynamic creation BPMN via API?
I'm trying to follow this document (https://docs.jboss.org/jbpm/release/7.3.0.Final/jbpm-docs/html_single/#_process_fluent_api) to use jBPM fluent api to create a process. But I'm wondering how to add ...
1
vote
1
answer
91
views
Getting 404 Not Found only when re-creating database in tests for 2nd API call
I'm trying to create API integration tests for legacy code I've inherited.
Currently I have a piece of testing code that:
recreate database (using Fluent Migrations)
starts a web app (Owin.Hosting)
...
0
votes
1
answer
59
views
How to create Find.Elements.By.Name(string name) in fluent API design?
Is this possible to create something like Find.Elements.By.Name(string name) using fluent api design pattern in c#? If so, how?
0
votes
0
answers
48
views
How to create a Fluent Interface that works in specific order [duplicate]
Hello i am trying to create a fluent API for an object.I create a builder object that will get its dependencies and then i will build the resulting object.
The problem is that i need to perform some ...
0
votes
2
answers
372
views
How to make a field set-able only inside extension method
Hello i want to be able to set the a of a field of an object only in an extension method. I would want that this field to either be completelely private , or be just get-able from outside:
public ...
4
votes
2
answers
2k
views
C# Creating a Fluent API for chaining methods
In C#, we can use Func<> and Action<> types to store what are essentially managed pointers to methods. However, in my experience, they need to be explicitly typed when defined: Func<int&...
0
votes
1
answer
121
views
Get keys from nested JSONObject fluently
I'm trying to extract a value from a nested JSONObject, say "id". I'm using org.json.simple package and my code looks like:
JSONArray entries = (JSONArray) response.get("entries");
JSONObject entry =...
2
votes
1
answer
296
views
Why Fluent Interface is called Fluent API
Why Fluent API is called "API" ? Fluent API is a way to create fluent Domain Specific Language, whereas API is "Appication Programming Interface". API is:
"A set of functions and procedures that ...
1
vote
1
answer
128
views
In EntityFramework 2.1 Fluent API Setting Audit Fields on Insert
Using Entity Framework's Fluent API, I can successfully insert a new row in the user's table using this code:
modelBuilder.Entity<User>().ToTable("Users");
modelBuilder.Entity<User>()....
0
votes
1
answer
286
views
How to get the autocomplition working correctly for inherited methods in PhpStorm?
There are two classes defined as follows:
class Foo
{
private $aaa;
public function setAaa(Aaa $aaa): self
{
$this->aaa = $aaa;
return $this;
}
}
class Bar extends ...
9
votes
1
answer
4k
views
Unable to send embedded image in email using FluentEmail
I'm using FluentEmail in ASP.NET core 2.0 class library which will be sending the Email notification.
Below is the sample code I have tried till now:
using FluentEmail.Core;
using FluentEmail.Razor;
...
2
votes
1
answer
243
views
method chaining child with parent classes using c++
Is there a way to chain calls to superclass from subclass without casting, overriding the method or using interfaces. E.g. when doing
class A {
public:
A& foo() { return *this; }
};
class ...
1
vote
1
answer
296
views
How to create a function with methods in Laravel
I need to create a function of this type, I do not know how it is done and I would like to learn
the function adds to the database, and receives some parameters
event($user)->balande(2.00)->...
2
votes
1
answer
1k
views
Python 3: Returning a new child class instance from an inherited method, when child constructor has more arguments than parent constructor
Suppose I have a parent class and multiple child classes, which extend the parent class by including more specific information about the ideas they represent. For example:
class Shape:
def ...
1
vote
1
answer
1k
views
Two foreign keys to one Entity Framework Core table
I am developing language dictionary with asp core 2.0. I wonder how to
properly design my database. I came across similar question: How to design a database for translation dictionary?.
I decided ...
1
vote
2
answers
52
views
How can I call function into function into class?
I'm exactly want to call function into function into class, like how exactly laravel works with oop php
example:
App\Flight::where('active', 1)->orderBy('name', 'desc') ->take(10)->get();
...
20
votes
2
answers
18k
views
How to chain multiple re.sub() commands in Python [duplicate]
I would like to do multiple re.sub() replacements on a string and I'm replacing with different strings each time.
This looks so repetitive when I have many substrings to replace. Can someone please ...
4
votes
3
answers
457
views
How to build a sequence using a fluent interface?
I'm trying to using a fluent interface to build a collection, similar to this (simplified) example:
var a = StartWith(1).Add(2).Add(3).Add(4).ToArray();
/* a = int[] {1,2,3,4}; */
The best ...
0
votes
1
answer
47
views
Is it possible to detect if fluent interface was called for the first time?
Let's say I have a class:
class A {
public A fun() {
System.out.println("a");
return this;
}
}
And a scenario:
A a = new A();
a.fun().fun().fun().fun();
a.fun().fun();
Is ...
6
votes
4
answers
4k
views
Difference between method chaining and fluent interface
I wanted to know the exact difference between method chaining and fluent interface.
As I understand it, method chaining is just running the methods of previous method return objects while avoiding ...
1
vote
1
answer
534
views
What is the difference between an extension method, the builder pattern and the fluent interface?
In Scala - we can do extension methods like this:
object MyExtensions {
implicit class RichInt(val i: Int) extends AnyVal {
def square = i * i
}
}
We can use it like this:
import ...
0
votes
1
answer
406
views
Fluent API with inheritance for validators - input validator instance seems identified as parent class
I'm writing a fluent API to validate key:value pair in a Map. I have a hierarchy of validator types. I referred to one answer from Fluent API with inheritance and generics.
public interface ...
1
vote
0
answers
234
views
Fluent Interface(chaining method) with C++ parallelism
Does anyone have an experience in using Fluent Interface (or chaining method) with SIMD and other levels of parallelism using C++? Is there any performance penalty, side effects, e.g. on instruction-...
8
votes
3
answers
25k
views
Fluent methods for data class in kotlin
We are familiar with fluent interfaces for calling methods in java and other programming languages. For eg:
Picasso.with(this).load(url).into(imageView);
This is made possible by setter methods what ...
0
votes
0
answers
394
views
Fluent API Method Call Chain - Use Reflection and Attributes to handle calls (C#)
I have a fluent API which I am trying to add another implementation for by passing in an enum to determine which object will be created and delegated to behind the scenes. It's for a UI testing ...
1
vote
3
answers
132
views
What are some good way to "reimplement" non-fluent interface as fluent one?
What I am looking for is, having non-fluent class:
class NonFluent {
int i=0;
public:
void setValue(int i) {this->i = i;}
void multiplyValue(int i) {this->i *= i;}
int getValue()...
4
votes
2
answers
3k
views
How can I make method chaining fluent in C?
There is an existing C API that looks like this:
//data
typedef struct {int properties;} Widget;
//interface
Widget* SetWidth(Widget *const w, int width){
// ...
return w;
}
Widget* ...
0
votes
0
answers
240
views
Is there a fluent way to continue from FluentIterable.index?
FluentIterable.index returns an ImmutableListMultimap, which ceases to be fluent.
That means if I want to transform the existing map I will have to wrap the entire thing in another FluentIterable ...
1
vote
1
answer
127
views
How to reuse common extended Interface method in Java?
I have these three Interfaces as part of the Fluent Interface API (where a lot of method chaining happens):
interface VerifierA extends VerifierC {
VerifierA method1();
// other ...
0
votes
0
answers
28
views
Fluent API with multiple generic parameters and inheritance [duplicate]
I am trying to implement a fluent API that contains specialized derived classes and I am using the Derived extends Base<Derived> method to obtain this parameter as Derived from base methods, but ...
0
votes
1
answer
39
views
wrong number of arguments error while building a chainable ruby api
In my gem I have a class called Client that I want to operate like this:
client = Client.new
client.content_type('pages').content_type
That means I want to set a property and then expect to ...