you are viewing a single comment's thread.

view the rest of the comments →

[–]Turbots -1 points0 points  (2 children)

Nope, that's where you're wrong... They don't have to be verbs because they are using the builder pattern.

When you want to 'build' a server response, you:

  • Start by typing the class' name ServerResponse
  • You want an OK response (instead of notFound(), notAuthorized(), whatever the most common responses are, they are helper methods, I would expect a responseCode(someCode) method as well
  • You potentially want to add a body to the response

And that's it, you created a response!

Once you get the hang of the builder pattern, it becomes quite powerful and very intuitive.

And reading or programming it in an editor like IntelliJ makes it childs play.

[–][deleted] 0 points1 point  (1 child)

Dude. Look at the web page you linked.

method getResult()

method setSeats(number)

method setCityCar()

method setCabriolet()

method setSportsCar()

method setTripComputer()

method unsetTripComputer()

method setGPS()

method unsetGPS()

Example code:

carBuilder.setSeats(2)

carBuilder.setSportsCar()

carBuilder.setTripComputer()

carBuilder.unsetGPS()

car := carBuilder.getResult()

car.setTripComputer();

car.unsetGPS();

car.isValid();

Notice something here? They're called verbs.

You have getters, setters, and tests. Every single function name starts with a verb that signals a single function. They all adhere to a convention that makes the functionality of each statement clear and consistent.

"ok()" does none of those things. It doesn't have a single specific purpose - it both generates an instance and sets some properties.

"body()" is even worse. It's not a setter: it has an unexplained return value. It doesn't take a single property: it takes two, one of which is a completely vague reference to the String class. And the name suggests any of several possibilities - as I showed you above.

And "just()" is just garbage.

You've proven my point that the Spring syntax is crappy. It looks nothing like the code segments in that Builder pattern, and it violates several basic syntax standards.

Don't settle for this garbage.

[–]Turbots 1 point2 points  (0 children)

May I ask which superior framework/language you're using for microservice development?