Skip to content

Flawed naming conventions #561

@prog110

Description

@prog110

Take a look at this API

client
  .headers(builder -> {
    builder.add(COOKIE, new DefaultCookie(SESSION_ID, "hello"));
  })
  .post()
  .uri("/uri")
  .send(ByteBufFlux.fromString(just("hi")))
  .response((httpClientResponse, byteBufFlux) -> {
    return just(sessionIdAndApiKey);
  });

When you look at the method post(), your intuition tells that the POST call is being made. But as per API, you are building a request that uses http POST method when the actual subscription happens & the request building ends with send AFAIK

This is a flawed api design as it breaks intuition. The same is true for all other http methods aswell. This flaw first appeared in WebClient API of Webflux & is now carried to reactor-netty aswell

Any action methods get(), post(), e.t.c would be considered by most developers as ACTION methods, not builder methods

A suggestion I have is to name these methods use<Op> (or) <op>Builder() (or) for<Op>, i.e client.useGet() (or) client.getBuilder() (or) client.forGet()

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions