Code Generation: Producing source or bytecode programmatically, e.g. an ORM generating SQL-mapping classes from a database schema. Code generation means writing programs that write code. Instead of typing repetitive classes by hand, a tool creates them from a schema, a template or a specification. You use it more often than you might think. php artisan make:model generates a model file. OpenAPI generators create API clients from a specification. GraphQL and gRPC tools generate typed classes from schema files.
What should you keep in mind with Code Generation?
It saves time and keeps similar code consistent. The rule is to be clear about which files are generated and which are written by people. Never hand-edit a generated file that will be regenerated, because your changes will be overwritten. Either commit generated files and regenerate them in a defined step, or generate them during the build and keep them out of version control.
Implement proven backend architecture patterns including Clean Architecture, Hexagonal Architecture, and Domain-Driven Design. Use this skill when designing clean architecture for a new microservice, when refactoring a monolith to use bounded contexts, when implementing hexagonal or onion architecture patterns, or when debugging dependency cycles between application layers.