Live data from Hacker News

Best Practices Exist For A Reason

tomdale.net

71–80 of 105 posts

Re: Best Practices Exist For A Reason

#71
post #58

Earlier quoted context omitted.

You can think about the effect of coding style instead of letting the experts think for you. If you are doing a Topcoder round, then the random Topcoder user's advice is probably better than Carmack's. Carmack or Torvalds would probably tell you to use a variable name that gives a lot of information about its purpose, so that other people will find it easier to read your code. The Topcoder user might tell you to use…

"You can think about the effect of coding style instead of letting the experts think for you." Right, because what could those experts possibly have to teach you? Fuck that intellectual crap, brogrammers are here to crank out some code yo! Just because those dinosaurs have spent "thousands of hours" studying and trying out different programming styles and concepts means I should listen to them? This is the internet a…

You completely and utterly missed the point, in addition to just being needlessly rude.

The point of your parent was "don't let the experts think for you", not "screw the experts" - that's a very important distinction. You should form your own opinions, not just uncritically adopt the opinion of some expert. It's unquestionable that expert knowledge and experience is important - but nothing beats forming your own (hopefully informed) opinion.

Re: Best Practices Exist For A Reason

#73
post #7

Earlier quoted context omitted.

That example gist went a long way towards convincing me of isaacs' comma prefix style. To me, consistency is important. All of my codebase is traditional comma postfix, so I'll keep using that; however, maybe with some new projects I'll try on the comma prefix pants and see if it helps. Thanks for the link!

To play at devil's advocate, please don't. Otherwise you should have written your comment like this: To me , consistency is important . All of my codebase is traditional comma postfix , so I'll keep using that ; however , maybe with some new projects I'll try on the comma prefix [...] ... using typography in a typographically sensible way is far more important to readability than an arbitrary "consistency" of punctat…

    And let me play the advocatus Dei
    , because that actually looks quite readable
    .
Though, more seriously, using English (a natural language) to try to make an appeal to absurdity about the format style of a formal language, is plain absurd.

Re: Best Practices Exist For A Reason

#74
If I could I would up-vote this post twice at least! And it is not the Java, node.js, where-do-you-put-your-semicolon part of it. I don't undersand any of it. No, it is more the view on best practices. And there, I completely agree.

I'm part of HN not for very long, but what strikes me are the similarities between supply chain management and programming in some aspects. The purely technical issues are out of scope here since I cannot judge them, it's more about the principles behind. Like in this case here.

Best pratices provide a guideline and are condensed experience. They are by no means the only or best solutions, rather ones that can be applied in a lot of cases withou screwing up. That said, one should also reach a point where understand them. One has to in order to understand when to use them, most people get at least to that point.

What you actually have to do is reach an understanding of not only when to use best practices but one of knowing why you use them. This is not true mastery, but it will get you far enough.

Ultimately, you need people who know when to use a best pratice, when to ignore them and when to actually brek conventional wisdom. What I see a lot lately is people doing the last to bits without having understood the best pratice's when and why in the first place.

For me, that's the key message of this post, and this point is valid in every industry, sector or task at hand.

Re: Best Practices Exist For A Reason

#77
;

Best practice is about a practice that helps create maintainable code. Code is maintained by people. So a best practice is really about getting the best code delivered by the people you have in the most appropriate time possible, and code that can be maintained by those same group of people and others who may be brought into the project at a later date.

Insisting on semicolons means that the bar to entry for being able to develop and maintain a JavaScript code base is lower. Also, we can spend more time thinking about the purpose of the code rather than it's syntax. That helps when it comes to debugging, spending more time thinking about what the code is trying to do rather than losing time figuring out whether the syntax without semicolons is causing an unintended side effect.

The lack of semicolons argument reminds me of the Python versus Java argument. Choosing python gives you a much smaller range of people who could work on your project, but on average the quality of that developer would be better than if you opted for Java.

The advantage of the non-semicolon stance is that they are increasing the minimum level of competancy before someone can work on their project. The disadvantage of the non-semicolon stance is that they are increasing the minimum level of competancy before someone can work on their project.

Re: Best Practices Exist For A Reason

#78

The main problem with appealing to "best practices" is this: One man's best practice is another man's anti-pattern. Between semicolon-free folks and JavaScript traditionalists, who gets to play the role of the expert? If Node.js is popular, does that mean that Isaac's comma-first style is "correct"? ( https://gist.github.com/357981 ) In the absence of a quantitative engineering method with which to evaluate either ap…

"Between semicolon-free folks and JavaScript traditionalists, who gets to play the role of the expert? If Node.js is popular, does that mean that Isaac's comma-first style is "correct"? (https://gist.github.com/357981)

No. Isaac doesn't define what style node.js is written in. And in an interview when he took on the lead developer role on he affirmed that he would abide by their current coding preference, which wasn't comma-first. That's Isaac in a nutshell, he works with the developers around him.

You may be mistaking Node.js with npm. npm is Isaac's code, and that is comma-first I believe. It's his project, and his rules, and his call as to what coding style he wants. People who participate in his projects either accept that, or walk away. Node.js is an existing project, so the existing coding preferences are in place -- unless, I guess, there's a general consensus that the coding preferences in place are causing an issue.

Re: Best Practices Exist For A Reason

#79

The main problem with appealing to "best practices" is this: One man's best practice is another man's anti-pattern. Between semicolon-free folks and JavaScript traditionalists, who gets to play the role of the expert? If Node.js is popular, does that mean that Isaac's comma-first style is "correct"? ( https://gist.github.com/357981 ) In the absence of a quantitative engineering method with which to evaluate either ap…

"In the absence of a quantitative engineering method with which to evaluate either approach, isn't it a purely personal and political choice?" No. Here's one idea: perhaps everyone's opinion is not equal on every subject. Perhaps by looking at the opinions of respected accomplished people who have garnered the respect of other respected accomplished people you can being to see who's opinion should get more weight. Th…

>And in the vast majority of cases, when you ask that question about a specific problem: One of those men is wrong. Even if they're both smart. But how to tell? If a huge number of other smart and experienced people have been convinced by one of them ... well I'd go with that guy. You won't be right all the time but it's the best system we've come up with so far for things that don't conform to double blind placebo controlled studies or mathematical proofs. It literally is the best way to be right most often.

This reminds me a lot of abstraction in software systems. For 95% of cases, the abstractions make things quicker in the end. For those 5% of edge cases which the abstractions don't cover properly, you spend inordinate amounts of time trying to get things to fit. The bigger point here is that trying to white-wash anything with a particular methodology is both the right and wrong thing to do. It's right because most of the time it will work, it's wrong because when it doesn't work, you will have a hell of a time dealing with it.

The best system we have come up with so far is actually to take things on a case-by-case basis instead of trying to solve everything in one fell swoop. The problem is that one must be mindful as consistently as possible to achieve this. Most people are not capable of keeping that line of focus for an hour, let alone a day or their whole lives. Funnily enough, the solution to this is meditation, not a set of best practices or expert opinions.

Re: Best Practices Exist For A Reason

#80
post #42
post #11

Earlier quoted context omitted.

Why does nobody ever mention the obvious solution? Separate var statements. They're always correct, they copy without any editing, and the "var"s line up to show that it's a block of assignments the same as commas or whitespace.

With separate var statements, you never end up with this situation: var foo = 1, bar = 2 baz = 3 In 90% of the cases the code will run the same whether or not there is a comma on line 2, but in the other 10% you will get burned in odd ways now that `baz` is a global variable.

JS Lint is your friend in this case. It will log that

* There's a missing semicolon on line 2

* There's a missing semicolon on line 3

* baz was being used before it was defined.

That's just in a global context. When it's in a function you get a little more:

* the baz line is indented too far - because it's being interpreted as a new statement.

Sure, you could eyeball your code looking for this. Or just use an automated tool that'd do it for you

Post reply on HN