We are a small / medium sized company with a dozen software developers that develop our own internal software for internal use. Since we are very few and there is a lot of work to do, for the most part, each developer manages a separate part of the system and does not share much of his work with other developers. Each one has his "domain", so to speak.
Occasionally, however, the domains overlap and we need to collaborate; and also the agreement means that it is difficult to replace people and when something goes wrong we must be there to fix things because nobody else can do it (at least not quickly). Therefore, this arrangement is pleasant (each of us has total creative control) and not pleasant (basically we are obliged to be on call 24 hours a day, 7 days a week, although in practice it is a bit more relaxed than that).
Recently we tested a small "workshop" among us to promote some better coding standards, namely unit tests. (Yes, we are one of the people who has not yet done so …) During the 2-hour meeting, our goal was to create a small sample program with unit tests, just to get an idea of how to do it.
They were 2 hours of fun, and in the end we managed to produce a bit of code, however, an interesting topic became painfully obvious: after having lived so long in isolation for so long, each of us basically has our own coding style.
Now, I'm not talking about eyelashes vs spaces, camel box versus snake box or some other cosmetic difference. I am talking about the principles of code organization. How to name things. In what folders and namespaces to place them? Do I divide this code into 3 classes or just one? 5 small files or 1 gigantic? Do you abstract it with interfaces and factories, or call it directly? Getters and setters or naked fields? Etc.
Sometimes, writing the absolutely trivial program almost turned into a shouting match, although fortunately we were able to remain calm in the end and no feeling was hurt.
So this made me wonder: how is the coding style normalized among multiple developers experienced with each their own strong preferences? The different styles certainly They are annoying when do They need to interact with the codes of others, not to mention that they are confusing for newcomers. And when a piece of domain code is transferred from one person to another, there is always a strong desire to rewrite it to match its own modes.
First, is there any rule on how to design your code? Any standard? So far I have only seen cosmetic things about spaces and cases. Basically, how to format your code once it is written (at least in your head). But is there any guide on how to write Your code, how to organize it and how to name it? Where and how to divide it into pieces and how to make them interact?
If there is no standard and we need to create ours, how is it done when everyone has a solid opinion about what is right and what is wrong? Now, look, we are all experienced developers here; We realize that none of our approaches is inherently better or worse than any other, only that each of them has certain strengths and weaknesses. But we also have a strong opinion about which strengths and weaknesses are the most important. So how do you decide on The Right Way ™ and how do you ensure that everyone adheres to it without hurting any (too much) feelings?
One way I've heard is to select a Glorious Leader who then forces his favorite style to others (through code reviews and meetings and whatever), but … you need a really good Glorious Leader who is really above of others. . What if you don't have one and we really are all the same here?