1

I'm looking for a tool/way to solve a problem that is a little difficult to describe in a simple Google search, so hoping you all can help -- if I'm in the wrong site, let me know!

Problem:
I am part of a small team of developers. We're friendly and get along well, but we have very different coding styles that we each feel strongly about. So far, we've all been working on different projects, so this has not been an issue. But, we will soon be working on the same code, and the conflicting code styles has the potential to make our code quite messy.

Possible Solution:
The obvious solution is to hammer out a shared coding standard, and have everyone change the way the code going forward. I really don't want to do this because:
a) In a sense, this is just not important enough to warrant the time and effort to sit and argue about this until we finally agree. Even though my teammate's style might drive me nuts, his code still works fine, which is all that matters to our boss.
b) This is simultaneously incredibly important and personal to each of us -- I hate even the thought of having to change the way I code just because I happened to be in a team with people who code in a different way. And, frankly, I'd be angry and resentful, and I'm sure they'd be too, so the resulting loss of team morale and friendliness might not be worth all this trouble.

Ideal Solution:
So, what I ideally want is to have my cake and eat it too: Have some tool/pipeline that converts our differently-formatted pieces of code into 1 single style (doesn't matter what) before committing it to our shared repo (so that our code isn't messy in the repo) and then, crucially, converts it BACK to our specific style when we check out the code to our local laptops (so that none of us have to change the way we code).

Is there a single (free!) tool that can do this for us? Or is this a very niche thing that I would have to hack together myself?

FYI, please note that I have very little CI/CD experience.

  • 1
    Style as in indents vs spaces and how many, etc or variable/method/class naming, or over all design pattern type stuff? – ivanivan Apr 7 at 2:33
  • @ivanivan I'd say both indents vs spaces, as well as naming. Basically any stylistic minutiae that doesn't really affect the functioning of the program. – Seth Apr 7 at 3:33
  • @ivanivan Actually, I take this back -- the only thing I would want to be changed is stuff like indents vs spaces, braces being on the same line vs next line, etc. Naming, design patterns, etc. don't need to be changed, as that's way too hard. – Seth Apr 7 at 16:53
0

Any decent full featured IDE like Eclipse or Netbeans should be able to reformat the code to an individuals preference, even doing it on each save of a file. Getting a version control system to do that may be much harder. More important would be for the VC system to recognize a change in format as not being a change in the actual file/code to keep versioning from going screwy as indents/tabs/spaces change. Note that depending on how different the styles are, a very complex *nix shell script using sed, awk and other text manipulation tools may be able to convert to a core standard format before check-in ...

Netbeans - https://netbeans.apache.org/kb/docs/java/editor-codereference.html

Eclipse - https://www.wikihow.com/Change-the-Default-Format-Settings-in-Eclipse

To do the same with naming of variables, methods and classes would be near impossible. Additionally, you have the issue of coder A referencing classes/methods/etc from Coder B and vice-versa. If these items are constantly changing as files get checked in/out of VC builds will break, etc. at least for Public or Package level properties/methods. Of course, the benefit of abstraction and encapsulation with OOP is that the private/internal stuff can constantly change and it shouldn't matter to anything that references it. But the part about a VC system going crazy still applies.

  • Sorry, I guess my earlier response to your comment was incorrect. The only thing that I would want to be changed by the VC system would be stuff like indents vs spaces, braces being on the same line vs next line, etc. I don't care about naming -- that can remain untouched. – Seth Apr 7 at 16:52
  • 1
    So, if I'm understanding this correctly, you're saying there is no VC tool that can gracefully handle a situation where it maintains 1 style in the repo but, upon checkout, automatically reformats the code to the local style of whoever checked it out. Instead, you're suggesting we do this manually via the formatter in our IDE -- i.e. before we commit code to the repo, we manually reformat it to the shared repo style; after we check out code from the repo, we manually reformat it to our individual style. Did I get that right? – Seth Apr 7 at 16:58
  • @Seth yes, basically – ivanivan Apr 7 at 17:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.