You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Also you can design in special comments into code files that are generated BUT also designed for Developers to add code to that same file , by using comment delineators. When the code generator is re-run alter, you can use there start and stop delineator to merge the generated code with the user code.
An early way to do this is to:
a. First gen run is just normal, and generates any code files designed to have users code changes with the special comments.
b. Next phase is to parse of all the code for files with these special comments, and copy each file in place from, for example, "file.go" to file". It's in the same directory, and so makes it easy.
c. Then parse all the code again looking for a match of "file.go" and "file.go.tmp", and then do the merge based on the special comments.
d. Delete "file.go.tmp"
The advantage of this approach is that the current generator is NOT affected. In stead we are just adding a 2nd phase. So this approach works fine with golang templates etc.
I used this technique for a very large Enterprise company that has a team for 500 developers. It was a total hit, and the developers liked it, because it solves an everyday problem and make it much easier to work with the code also. We were generating off a custom schema and we would generate the DB and Middle tier. The merging strategy did work well.
Please let me know if this is helpful ?
The text was updated successfully, but these errors were encountered:
gedw99
changed the title
mark code that is designed for a Developer to change clearly
Clearly mark code that is designed for a Developer to change
Aug 23, 2024
Hey @lerenn
2 things I want to ask for help with:
When I look at https://github.com/lerenn/asyncapi-codegen/tree/main/examples/helloworld/v3
All the going code has generators, and so you cant easily tell which code is your code and which is generated code.
A big and clear comment at the top of the files that are designed for a User to change that the generator will stomp on is the solution I think.
https://github.com/lerenn/asyncapi-codegen?tab=readme-ov-file#with-async-api-generated-code explains the notion of User Code versus Generated code.
Also you can design in special comments into code files that are generated BUT also designed for Developers to add code to that same file , by using comment delineators. When the code generator is re-run alter, you can use there start and stop delineator to merge the generated code with the user code.
An early way to do this is to:
a. First gen run is just normal, and generates any code files designed to have users code changes with the special comments.
b. Next phase is to parse of all the code for files with these special comments, and copy each file in place from, for example, "file.go" to file". It's in the same directory, and so makes it easy.
c. Then parse all the code again looking for a match of "file.go" and "file.go.tmp", and then do the merge based on the special comments.
d. Delete "file.go.tmp"
The advantage of this approach is that the current generator is NOT affected. In stead we are just adding a 2nd phase. So this approach works fine with golang templates etc.
I used this technique for a very large Enterprise company that has a team for 500 developers. It was a total hit, and the developers liked it, because it solves an everyday problem and make it much easier to work with the code also. We were generating off a custom schema and we would generate the DB and Middle tier. The merging strategy did work well.
Please let me know if this is helpful ?
The text was updated successfully, but these errors were encountered: