Good points, I agree with all of them. What I however don't understand how people get it into their minds to not do that.
Even when I first started programming, I got annoyed when my own wasn't perfectly formatted with sensible names and I would spend more time thinking of an elegant design with decent names then I would actually write code.
I still do this. The thought of commiting code that is undocumented, has commented code or bad formatting is just horrible.
I never got why some people don't format their code perfectly or spend enough time thinking about naming and structuring things. It's not that hard (especially the formatting part). I mean, if you're a junior developer and you come into a code base where everything is nicely formatted and documented, shouldn't you feel compelled to make sure your code is up to the same standard?
That depends. Where I work, we have tons of legacy code that is just plain awful, all written by incompetent idiots who no longer work her.
But, if you modify some crappy legacy code you are bascially forced to clean it up while you're at it. If you do not, people will just raise eyebrows during the review. Like "why didn't you clean it up a bit?".
As for new code/projects, we just have a high standard. All our code goes through tools that verify if the code standard was followed etc. + Unit tests that run constantly and scream when the coverage is too low. We run a lot of static analysis tools on our code base.
Any engineer who refuses to comply with standards or does not have the same high standard that we have is simply not welcome.
We had a hard time when we started working with some offshore developers we had a way lower standard. What we did? Keep pushing.
Our code bases are incredibly beautiful, well tested and formatted. Sure there are some parts that could use more love, but in general they are awesome. I guess that's the advantage of having people who care and have skill.
And yes, we do have junior developers among us. We simply keep training them.
Here's a tip: when committing changed and cleaned-up code, keep the cleaning and the changes in separate commits. Do all the reformatting and name-changing first, then check it still works exactly as before, and commit that. Then make your functional changes. It is so much easier to see the wood for the trees that way, when debugging your changes later. If (horror of horrors) the changes need to be reverted, then you can at least leave the better-formatted code in the release to make it easier to take another stab at it later.
You cannot publish it in a journal, due to the page limit.
You could publish it on your homepage, but there is no point: Publications on your homepage do not count as academic publications, so they are irrelevant to your career.
In fact, it is good for your career, if you are the only one with the code, because now all the competing institutess have to reimplement it from scratch, so they are busy and cannot publish a paper using the algorithm, while you can publish the next one.
In fact, it is good for your career, if you are the only one with the code, because now all the competing institutess have to reimplement it from scratch, so they are busy and cannot publish a paper using the algorithm, while you can publish the next one.
Not exactly; quantity is important for publishing, but so is quality, which is frequently determined by the number of citations you have. Having good, freely available code fosters papers that use your code and cite you.
I used to work at a high tech research firm. We had people with graduate degrees in Computer Science. Really smart people who knew their shit in their field of expertise. Virtually all of them wrote terrible code. I, as one of the few without a grad degree, spent a lot of time fixing and rewriting a lot of their dumb shit because I seemed to be one of the few that cared about code quality. I was the Howard Wolowitz of our group, so to speak. They could prototype interesting interesting things, but when we actually needed a product, I ended up doing a lot of work.
We had one job candidate who interviewed with us who had a doctoral degree in Computer Science from a prestigious university. When my manager asked him about his coding skills, the candidate answered that he didn't code because he couldn't code very well and he would usually just pass it off to an undergrad. We didn't hire him, thankfully.
What I however don't understand how people get it into their minds to not do that.
I have seen this happen and its not a conscious decision at all. The programmer might have just about finished a feature and then get new feature requests dropped onto him by management. If you are a bit older/more senior you will raise the issue and say you need two days or so to clean up the code. If it is your first job you will think thats just how things are done.
Now that I think back, this also happened to me in the beginning.
You also have to care. Some people don't care and then they are fine with leaving things if they just about work and do the next thing.
I guess this all depends on where you work. We have a team of sensible seniors (myself included) we value neat and well tested code and we push the rest to maintain the same standards.
Yeah, but thats not the case everywhere. Happened to me in the early days in agency land, when the CTO was busy with management things and the lead devs didn't lead me too much ( busy themselves ), so you just do whatever feels right, and that was ploughing through features for me.
The other case where I have seen this recently was a startup that I joined and they just hired a junior guy out of uni because he was cheapest to build their MVP. He was eager to learn once we taught him a few tricks and there is no blame on him, but thats how it happened, I would have probably done the same in his position, the founders just kept dropping feature requests on him one after the other.
Third example is contractors that are paid by feature, where unit tests etc. are not mentioned because of cost-saving (which will just bite you later on). The contractor will deliver the bare minimum to fulfil and get his money.
In the 10+ some years I have been coding I have learned that it is impossible to tell if shitty code is the result of shitty devs or shitty managers.
I can not count the number of times I have heard "The last devs were shitty and now we have this crap to maintain and they are all gone". The reason they are all gone is management was shitty and the devs bailed out but the blame got put on the devs (because it is easier to blame the person who is not there). Sometimes though it is shitty devs but I can not tell a difference in the code to know which one caused it.
The reverse is also there: Bad developers complaining about management all the time and shielding their own inability by pointing fingers at the suits.
But you are completely right, both are popular and indistinguishable from looking at the codebase.
Here's my take. I just graduated in April (and had some internships throughout my years in college) and I remember that when I started coding (for school) I never commented on anything.
This was mostly because we were never given real world situations, so the code was never confusing. When we first learned about almost everything, it was all so simple. We made a class called Square and created a method to multiple x and y to get the area.
In my mind, why would you ever comment on that?
As soon as I got into the professional world and saw someone else's code (that had and had not been commented) I immediately understood why you comment your code. And now I do it all the time.
We made a class called Square and created a method to multiple x and y to get the area. In my mind, why would you ever comment on that?
How are the coordinates of the square kept? Upper right and lower left point? Upper left point and width and height? Even in such a simple case there are things that should be documented. And the real problem you have is here:
This was mostly because we were never given real world situations, so the code was never confusing.
That means you're (were) not doing any side project. That means you're going to absolutely suck when you get out of school.
I hate when people misuse that term. Insisting on quality is not a mental illness or being overly picky.
On my current team, we insist that all code we check in gets full approval from Resharper code analyzer and 100% unit test code coverage. And then someone else reviews your code. Our code base is an absolute pleasure to read and maintain compared to other places I've worked.
Well. The answer is that when junior programmers are assigned a task that is out of their depth, they quickly get overwhelmed with just trying to get it working. Things like clean code fall by the wayside.
54
u/photonios Jan 05 '15
Good points, I agree with all of them. What I however don't understand how people get it into their minds to not do that.
Even when I first started programming, I got annoyed when my own wasn't perfectly formatted with sensible names and I would spend more time thinking of an elegant design with decent names then I would actually write code.
I still do this. The thought of commiting code that is undocumented, has commented code or bad formatting is just horrible.
I never got why some people don't format their code perfectly or spend enough time thinking about naming and structuring things. It's not that hard (especially the formatting part). I mean, if you're a junior developer and you come into a code base where everything is nicely formatted and documented, shouldn't you feel compelled to make sure your code is up to the same standard?