Live data from Hacker News

Ask HN: Javascript best practices?

news.ycombinator.com

41–50 of 52 posts

Re: Ask HN: Javascript best practices?

#41
post #38
post #36

When I hear "best practices" I reach for my Giant Spiked Club of Holy Wrath.

Why? What's so terrible about finding out about how those more experienced than yourself do things? I'm assuming, of course, that sound reasoning is supporting the practice rather than simple cargo culting.

It's cargo culting more often than not.

For some reason, people don't follow good advices which require changing code logic, refactoring and such: they follow advices where you need to format everything in the longest possible way and write a lot of boilerplate.

Because it's just easier for some people.

Re: Ask HN: Javascript best practices?

#42
post #40

* Comment with JSDoc style * Auto-build docs and script for development and production environemnts (easy to concatenate and then pipe this to YUI Compressor) * Use an MVC project organization or something like-minded. You can't just throw files representing widgets around. * Write unit tests. JSUnit and SrewUnit (I prefer the latter) work well for this. * Format your code nicely (this goes for any code but I find a…

also: http://dev.opera.com/articles/view/javascript-best-practices...

Unfortunately they recommend the bad variant of hungarian notation. Bad, bad, bad :-(

Re: Ask HN: Javascript best practices?

#43
I like Douglas Crockford's opinions and advice on many aspects of JavaScript:

http://javascript.crockford.com/

Conventions:

http://javascript.crockford.com/code.html

and his book "JavaScript The Good Parts" is well worth a read, even to experiences JS developers

http://www.amazon.com/exec/obidos/ASIN/0596517742/wrrrldwide...

Re: Ask HN: Javascript best practices?

#44
post #42
post #40

Earlier quoted context omitted.

also: http://dev.opera.com/articles/view/javascript-best-practices...

Unfortunately they recommend the bad variant of hungarian notation. Bad, bad, bad :-(

Which variant of hungarian notation do you prefer?

Re: Ask HN: Javascript best practices?

#45
post #42

Earlier quoted context omitted.

Unfortunately they recommend the bad variant of hungarian notation. Bad, bad, bad :-(

Which variant of hungarian notation do you prefer?

See http://www.joelonsoftware.com/articles/Wrong.html, particularly the section "I'm Hungary", for a comparison between two different styles of Hungarian notation.

Re: Ask HN: Javascript best practices?

#46

* Comment with JSDoc style * Auto-build docs and script for development and production environemnts (easy to concatenate and then pipe this to YUI Compressor) * Use an MVC project organization or something like-minded. You can't just throw files representing widgets around. * Write unit tests. JSUnit and SrewUnit (I prefer the latter) work well for this. * Format your code nicely (this goes for any code but I find a…

Great points Just curious. For large scale projects, do you suggest building on top of existing javascript libraries (i.e. prototype, jQuery, mootools, etc)?

If it's UI-based, I'd use ExtJS. Otherwise, MooTools. Both of these are very performant and give you a lot to work with in a neat package. jQuery UI, MochaUI, etc. are all miles behind ExtJS when it comes to behaving (reliably and efficiently) as a real tookit (with widgets and layouts).

In my opinion, jQuery is suitable for progressive enhancement but not for dedicated apps.

Re: Ask HN: Javascript best practices?

#47
Big topic, here's things i refer to repeatedly

http://yuiblog.com/blog/2008/09/26/oojs/

http://yuiblog.com/assets/pdf/oojs-ch-8.pdf

http://mashraqi.com/2008/07/high-performance-ajax-applicatio...

http://www.smashingmagazine.com/2008/09/16/jquery-examples-a...

http://dev.opera.com/articles/view/the-seven-rules-of-unobtr...

http://www.reddit.com/r/programming/comments/7rtxa/has_anyon...

http://code.google.com/p/jslibs/wiki/JavascriptTips

Re: Ask HN: Javascript best practices?

#49
post #45

Earlier quoted context omitted.

Which variant of hungarian notation do you prefer?

See http://www.joelonsoftware.com/articles/Wrong.html , particularly the section "I'm Hungary", for a comparison between two different styles of Hungarian notation.

I remember having read that before; will take a new look and implement the good parts in my code.

Thanks!

Post reply on HN