I've been noticing that modern frameworks tend to have this kind of code style:

expect(6 - 4).toBe(2)

this can be rephrased as: assert(6-4, 2)

Yet the former is much more readable.

I would like to read more about this "style" of coding, but I have no idea what to search for. Does this convention have a name?



It's called a fluent interface.

Some people may call it more expressive, but "more expressive" means that you couldn't 1:1 replace it with another language's statements, which you do in your second example. So, the first example is not more expressive, but it is certainly more fluent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.