4 ms·
> …to refactor and improve the quality of a microservice. > … > It worked. It vastly improved the code base… That sounds like an amazing learning oppor
by burnerToBetOut 8mo ago
> …to refactor and improve the quality of a microservice.
> …
> It worked. It vastly improved the code base…
That sounds like an amazing learning opportunity!
Would you be up for sharing before refactor and after refactor versions of your experiment in a public repo?
Thanks in advance.
- deleted 8mo ago[deleted]
- fvdessen 8mo agoUnfortunately not, it's private company code. But I can share the prompt I used for the refactoring: - 1. Read the whole code of the repository. - 2. Read the TASKS.md file if it exists. - 2.1. If it exists and is not empty, pick a refactoring task from the list. Choose the most appropriate. - 2.1.1. Refactor the code according to the task description. - 2.1.2. Commit the changes to git. - 2.1.3 Remove the task from TASKS.md - 2.1.3. You are done. - 2.2. If it doesn't exist or is empty: - 2.2.1. Identify the parts of the code that could be refactored, following the following principles - A class should have a single responsability - The dependencies of the class should be mockable and injected at class instanciation - Repeated code should be factored into functions - Files shouldn't be longer than 1.5K lines - 2.2.2: If using the previous insights you think there is valuable refactoring work to be done: - 2.2.2.1 Write a list of refactoring tasks in TASKS.md - 2.2.2.2: You are done. - 2.2.3: If there is no more refactoring to be done, notify me with 'say "I am done with refactoring"'
- burnerToBetOut 8mo agoAwesome! Thanks again! > …Read the TASKS.md file if it exists… What about sharing that TASKS.md? I'd like to replicate your success as closely as possible. Having the same tasks would help me nail a similar successful result. I forgot to also ask: What language and which REST framework was your microservice implemented with? For even better reproducibility, I'm thinking I should have my codebase be as similar to yours as I can get it. TIA!
- fvdessen 8mo agoThe TASKS.md file will be created and filled by the model. The prompt needs to be run repeatedly in a loop until it decides there's nothing to be done anymore. The service was in go, but this doesn't matter.