Is Programming Style important? How Important? [cl

2020-02-08 03:22发布

Last year I was troubleshooting a team member's code and it was lacking indents and comments. I was talking to him about it telling him it was not a good idea but he got offended. He was/is smarter than me or certainly more educated.

Since then I found out he applied to Microsoft and when they had him do a doubly linked list implementation, he wrote it without indentation or comments, stating that he did not have time to worry about style. ( It was an email submission for which there were 2 hours to complete )

Microsoft did not call him back..... How do you think they responded, how would you respond?

Anyone from Microsoft on here that can suggest what they would do in this case?

30条回答
别忘想泡老子
2楼-- · 2020-02-08 03:54

About "style" (which I'd rather call "formatting"): it is largely a matter of personal taste, but working in team is very important defining some guidelines which EVERYONE must follow, bending his/her personal preferences if needed (in Eclipse we export the formatter configuration and with a keypress we get the file formatted). Very soon everyone will get used to the standard and reading code will be very less fatiguing.

About comments: I prefer a good naming for my methods, but a comment on two on the most obscure parts are mandatory.

查看更多
别忘想泡老子
3楼-- · 2020-02-08 03:54

In my opinion, saying that style isn't important is like saying that spelling isn't important. If your style (or lack of style) is causing readability issues, then it will be difficult for a team to work with the files that this person is writing/editing.

Similarly, if a programmer doesn't take the time to spell words correctly in comment blocks, function names, etc....it will cause issues with other developers trying to decipher code. I always ask myself, "self, if you look at this in 1 week, will you understand it? If you look at it next year, will you still understand it?" (or at least be able to read documentation/comments to jog your memory).

To me, style is not important when you are talking about putting the curly brace on the next line of your if-block versus putting it at the end of the conditional statement...as long as it meets your coding standards, is internally consistent, and the rest of the team uses the same approach; with that being said, I feel that style is extremely important if it impacts the readability of the code.

With MS being such a large company, they probably are looking for someone who can be a problem solver as well as a team player. Someone who states that they "don't have time for styling" would come across as not a team player, to me.

Nice question!

查看更多
smile是对你的礼貌
4楼-- · 2020-02-08 03:57

There's little excuse for not commenting and none for not indenting. Indentation is handled by most of the best editors and commenting should come as second nature for somebody who MS might like to hire.

They're certainly both disciplines that people get into (either naturally or through schooling) so not showing either, perhaps, shows a lack of discipline, or, at least effort to express it.

Edit: 2 hours for a linked list?! I see he meant now... Fitting in all that formatting in the remaining one hour, fifty minutes would have been pretty tough! (I'm only playing around - I assume there was more to the interview than a linked list!)

查看更多
姐就是有狂的资本
5楼-- · 2020-02-08 03:57

Coding style is fairly important. Most major development companies have a document that defines required naming conventions, commenting guidelines, and other little things to do with code style and architecture guidelines.

All of which is very good and helps to promote a working environment in which team members can have good expectations of what their colleagues code will look like.

Just make sure it doesn't get down to the level of a manager forcing a developer to make a change in a code review from something like this :

if( someBool() ) doSomething();
else doNothing();

To something like this simply because they "feel" its the "better" style :

if( someBool() )
{
    doSomething();
}
else
{
    doNothing();
}

Just please have reasons better than personal preference for style requirements and we can all be happier.

查看更多
爷的心禁止访问
6楼-- · 2020-02-08 03:58

Programming without identing and a readable style is like writing a book without paragraphs and pagebreaks. It's just a great bunch of text and I would never take time to understand it.

I fully understand the reaction of Microsoft - I wouldn't call him back too.

查看更多
疯言疯语
7楼-- · 2020-02-08 04:06

Well, the fact is that the software life cycle phase in which it lives the longest is maintenance. During that time it is mostly read and analyzed by humen trying to fix it, reuse it, enhance it, etc. That is the best reason to keep it easily readable and understendable. Someone stating that he has no time to worry about style, which explicitly influences readibility, shows only his immaturity as software engineer. Or maybe simply no understanding of software life cycle.

查看更多
登录 后发表回答