Description
Take a look at this
databaseClient.execute()
.sql("INSERT INTO legoset (id, name, manual) VALUES($1, $2, $3)")
.bind("$1", 42055)
.bind("$2", "Description")
.bindNull("$3", Integer.class)
.fetch()
The method name execute()
sounds & feels like we are executing something, not building a query for execution. For comparison, just try to understand what is fetch
& what is execute
in general. Both are ACTIONs, but the API expects us to treat them differently for no good reason. For a user who knows nothing about Spring Data R2DBC, execute
API is not at all intuitive
I saw the same flawed naming convention being followed in WebClient
api of webflux when it comes to building http requests, i.e inorder to build a GET
request, they expect us to write webClient.get()
, but this sounds & feels like we are making GET
call when we are writing it (as per intuition), but we with WebFlux
api we are not making the call with get
, rather we are informing the API to return a *Builder
/*Spec
that will eventually make a GET
request. Its a flawed API design as it breaks intuition
I have couple of suggestions about it
Either name methods that build something with op<Builder>()
(or) for<Op>
, i.e for building execute
statements use databaseClient.executeBuilder()
(or) databaseClient.forExecute()
The first one is more direct & does not leave any space for any confusion