I really like this article about leaving the code/camp site in a nicer state than you found it - it seems like a practical approach in the real world to keep on top of code cleanliness.
I also really like feature branches as a way of developing features in isolation so that, if you don't like it, you can easily not merge it etc.
However, if I'm working on a feature branch, and I spot some ugly code, should I fix it?
It feels like there are a number of down sides to fixing it:
- When I merge the branch back in, the diff will be messy, cluttered with variable renames or function extraction
- If the feature gets abandoned, you either have to cherry pick the cleanup commit (which may or may not work depending on how the code near it has changed making a messy merge), re-do it or just abandon it.
On the flip side, if I don't do it whilst I am in the file, then clearly I'll forget to do it in a couple of days time when I merge the branch in.
I was warned this was opinion based (I think just off the fact the title includes should
), but I feel like there is an answer (certainly people use both these approaches so they must have an answer). Also, questions about development methodologies
are on topic and I think they necessitate a degree of opinion.