17 votes
Accepted

Chaining list operations in Python

This is more "streaming" in a sense: ...
user avatar
  • 3,981
11 votes
Accepted

Simple builder pattern implementation for building immutable objects

First of all, very good job. Now I will point out a few things that I think can be improved on. Code Duplication You have copied over all the private fields from ...
user avatar
8 votes
Accepted

Fluent API for creating random integer arrays in Java

Ouch. That's a lot of code to do things that are already available in the native Java libraries. Also, while the usage code "looks" neat, writing it is a PITA because it returns a different object at ...
user avatar
  • 96.7k
8 votes

Fluent Validation of Objects

Fluent API Fluent APIs are generally very useful but one has to be very careful with them as there is a chance of making them overfluent. This means that you try to create an API for every possible ...
user avatar
  • 43.8k
7 votes
Accepted

Initializing immutable objects with a nested builder

When I think of immutable object I think of get only properties backed with readonly fields. ...
user avatar
  • 8,418
6 votes

Chaining list operations in Python

It is possible to write those steps in a single comprehension -- sort of the Python analogue for chaining in JavaScript or Ruby. It doesn't read too badly if you convey the logic visually. Without ...
user avatar
  • 10.1k
5 votes

Simple fluent library to validate text content

I'll take time to review just one of the APIs which I find is the most confusing one: ...
user avatar
  • 43.8k
4 votes

Fluent API for creating random integer arrays in Java

I think you've overcomplicated things for yourself. A fluent API on top of @rolfl's suggested alternative may have a merit, if it's fluent in a more traditional sense. In particular, I think the ...
user avatar
  • 107k
4 votes

Fluent Interface for a XmlQueryBuilder

ToString() does too many things, it should only be calling _xDoc.ToString(); it has side-effects that make it dangerous to call ...
user avatar
4 votes

Simple builder pattern implementation for building immutable objects

If you would use Lombok, you can get the same classes with less code: ...
user avatar
4 votes

Simple builder pattern implementation for building immutable objects

You can simplify your builder by removing the final specifiers from the fields of Person. Don't worry, unless you add setters ...
user avatar
  • 25.6k
4 votes

Methods to create C# dictionaries, with static keys/values, in fluent notation

This sounds like a good idea but I don't think it is, at least not with the current method names that I agree with @denis are very confusing. The name KeysToValue ...
user avatar
  • 43.8k
4 votes
Accepted

Database abstraction layer for multiple providers

DbProvider<TConnection, TCommand, TData> In the ExecuteNonQuery() method you are doing stuff before you check the passed ...
user avatar
  • 50k
4 votes
Accepted

Pizza maker with Bloch builder

Your main() code feels cumbersome, and the modelling seems unnatural to me. I also find that ...
user avatar
4 votes
Accepted

Constraining a property setter fluently

This might actually be useful in some cases, however, we first need to get rid of its weaknesses and clean-up the code a little bit: Every property of ...
user avatar
  • 43.8k
4 votes

Fluent Validation of Objects

This API does feel fluent for consumers to use. You have also included some features I missed in the post you were inspired by. various severity levels [warning, error] custom error messages (...
user avatar
  • 13.8k
4 votes
Accepted

Fluent Validation of Objects

Cleaner consumer interface WarnIfTrue / WarnIfFalse ...
user avatar
  • 5,407
3 votes

Table printing code using a fluent interface

Which is easier to read? How would you improve either of them? Do either paint us into a corner? I love A. It is simple, clear, concise and meaningful. B is the same as A but with one major ...
user avatar
  • 9,195
3 votes

Methods to create C# dictionaries, with static keys/values, in fluent notation

Your Dictionary<,> instantiation doesn't looks fluent to me at all, instead it looks overly-coupled with all kinds of extension method calls and it's kinda ...
user avatar
  • 8,418
3 votes

Find attribute on class property

I think that Heslacher is right and you don't strictly need this class, but as you've written it I'd like to point out a couple of things: Many people, myself included, don't like to use ...
user avatar
  • 16.6k
3 votes

Finite State Machine supporting shortest path transitions

Runnable Review From Reference Docs: When an object implementing interface Runnable is used to create a thread, starting the thread causes the object's ...
user avatar
  • 13.8k
3 votes

Pizza builder with fluent interface

Some suggestions from my side: I don't like the bi-directional dependency. A Pizza shouldn't depend on the builder. A Builder is usually rather used to create complex objects. By creating a bi-...
user avatar
3 votes
Accepted

Switch-like functionality for non-switchable types in Java

Bugs Unfortunately this doesn't work as expected Assuming that breakWhen works like break in a regular ...
user avatar
  • 10.3k
3 votes

Chaining ConstrainableSet<T>

Like Pieter Witvoet I don't quite understand which problem this code is trying to solve. There is an ObservableCollection Class that partly does the same. Together with validation logic in properties ...
user avatar
3 votes

Builder pattern in C# supporting subclassing with nested classes

I'm not sure this qualifies as a review, but here we go anyways. Don't do this. This is one of the classic use of a design pattern where we shouldn't use one. A design pattern is a solution to a ...
user avatar
  • 12.3k
3 votes

Java Fluent Wrapper

Yes, your implementation is sound and possible...however, it doesn't make any sense to have it in the first place, at least not for your example. ...
user avatar
  • 7,637
3 votes
Accepted

Instantiating Person objects using the builder pattern

The only advice I have is: Don't do that. You're abusing generics, massively, IMO. A data class where all the properties are val is the best compile-time validation ...
user avatar
2 votes

RPG Character with fluent interface

While it may be a "valid" implementation, it is not the best, and could stand for several improvements. I've outlined a couple. This bit: ...
user avatar
2 votes
Accepted

Attempting a fluent API for creating random int arrays

Range limits of integer math: rand() % (maximum - minimum + 1). Should the user have minimum == 0 and ...
user avatar
2 votes
Accepted

Fluent Repository/QueryBuilder

I quite like the concept. The only thing that stands out for me initially is that I would probably leave the wrapping methods the same as their wrapped name. i.e. ...
user avatar
  • 6,407

Only top scored, non community-wiki answers of a minimum length are eligible