Question

I'm often modifying code that was written by others. I've seen a lot of code formatting standards and I'm a bit confused what I should do. Should I always stick to my own standard or adjust my standards to the one used in the framework?

Currently I'm always switching my standard to the one that is used by the framework but it messed up my own standard. I recently caught myself using a lot of different code standards in one application.

I was thinking of running a beautifier over all projects that I'm working on but that doesn't seem to be an options since all of them are also maintained by other sources so if there's an update every beautify change will appear in git and cause me some merging work.

Was it helpful?

Solution

In case you are working with others, in a team, usually the team lays down some sort of formatting or coding guidelines, just to avoid having to jump between coding styles.

I think that the people who maintain your codes, if you are working as a team, should do the same thing. Whatever coding language it might be, settling for a standard formatting can save everyone a lot of headache, so there's that.

Also, in my experience, same goes for frameworks. Even though I hate the formatting of the Twitter Bootstrap CSS, I do use it when editing those files, because breaking an already existing standard in a file is the worst case scenario and investing time into reformatting an existing code just sounds like a waste of time. You can always link other files in too with your own formatting, if that is no concern.

I think some code editors offer code formatting scripts, where based on the language and your selected preferences, they reformat your code for you if you want to, but I personally never used such a thing, that might be interesting for you (only saw such thing in action in CodeBlocks).

I think you should assimilate (might be the weak man's choice, heh) and keep your own formatting for your own projects. It just saves time and keeps you from headaches.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top