when a new guy joins a team...
Not so long ago, I was browsing merged pull requests to check quality of the work that was done. I don't know why, but in 202X C# is rather a modern language and some language syntax shall be adjusted to newer standards. When I was starting my developer journey - I was told to always add a code that looks similar to the one that already is there, unless it is total crap and adding new stuff needs more effort today, to not to die tomorrow.
But in this case, we have a project that is created in in 202X and there is a lot of good looking and working lines of code around, so anyone can follow it.
First time, when I was a student and helped my colleague, I was in shock that the teacher recognized my help, I turned all red and asked him "how you were able to recognize that?". He said that most of us have a kind of style that identifies us as developers, so this is spacing, the way how we organize braces (even when autoformated), how we write and solve problems, and finally variable names. Then in 3 we have a look at the code and he pointed out areas when I helped my colleague. It was rather embarrassing, but truly a great lesson how to deep look on the code. We had a happy end as my colleague was able to answer all questions and explain why it is working, but the wild and angry look of all other students at us was in us for next 3 minutes...
Now the text is based on a fact that a new person joined a team, and as far as I know the developer has a lot of experience in the area. So, let's have a look at a code snipped below, where I renamed the DTO to "SomeElement" and cut some stuff that is not needed to make it simpler. This code was added, not modified.
...just read it twice and think what can be better there...
OK, so let's think:
- looks like we are dealing with a data access layer
- we have an object mapping
- and wtf is "SplitValue" doing there?
line 6:
declaration of a variable - imho it is not needed here, as we are re-creacting this object in line 14 on each iteration step. I am wondering if that makes any difference. Let's check it and execute another benchmark.
line 7
line 8
line 10
line 25+
Every piece of code shall adhere to other elements that are already there, so we humans can read and understand it faster (executing CPU does not care about that so much). We need to ask: is that check line needed? Is there a way to make it simpler for a person with less experience?
When someone joins new team there is a need for a co-operation so all standards are provided and adhered. What funny I found (and this is not this case) that most seniors are not adhering to the codebase standard but rather to their's ones, as we come here with experience to do our job.
Comments
Post a Comment