from Hacker News

Which tricks do you use to write less code?

by jordiburgos on 5/10/24, 2:12 PM with 1 comments

I found some "tricks" to write less code, hence less code to maintain if there are any changes. Also less code with bugs just by changing the inputs.

For example, OpenAPI spec file + OpenAPI generator (https://github.com/OpenAPITools/openapi-generator). Any changes in the OpenAPI spec are reflected in the final code with a build step.

Another example: MapStruct (https://mapstruct.org/) to avoid passing data from Entity classes to DTO and back. Saves looots of boilerplate code.

I don't have much to say for frontend as I am mainly working on backend. So good to know your stuff.

Which are your tricks?

  • by h2odragon on 5/10/24, 2:20 PM

    two or three letter variable names. If your scope has more than 17k variables you're doing something badly wrong anyway.