

Ask HN: How to write OO JavaScript that is both readable and IDE-compatible? - andrea_sdl

Lately one of my coworkers started refactoring some JS using inspiration from John Resig advice (http:&#x2F;&#x2F;ejohn.org&#x2F;blog&#x2F;simple-javascript-inheritance&#x2F;).
Until this, we were writing plain old js.<p>The code now is more structured, clean, and obviously better.<p>My coworker is a super-great programmer, I personally respect him very much both humanly and professionaly, but this whole refactoring has made me thinking about one thing, and that is: IDE Compliance.<p>We are using an IDE (netbeans in this case) to develop our app, but I found that if we write JS this way the IDE won&#x27;t give autocomplete suggestions decently.
So, while we get all the beauty of OOP, we don&#x27;t get to know what are the available methods of an object unless we &quot;remember&quot; them.<p>Personally I think this can and should be improved because if another person comes onto the team he&#x2F;her wouldn&#x27;t know how to interact with our &quot;framework&quot; unless he starts digging into the code.<p>What was your experience on this? 
Is there a way we can write clean OO JS code that is also indexable from an IDE?
======
rnovak
I'd personally suggest using a better IDE. It may be "expensive", but I've
bought personal licenses for IntelliJ products a while ago, and renew yearly.
It's a very small price to pay for productivity. Not to mention, they're truly
cross platform, and I can go from working on my Windows box at work, to
working on my Linux or OSX box at home, all in the same exact IDE.

WebStorm seems pretty good at JavaScript prototyping/inheritance and auto-
complete.

~~~
andrea_sdl
Yup, I also came to the same conclusion. Have you tried Webstorm/INtellij in
such cases?

I know they are good (using webstorm for Haptime, my product, and was a long
fan of IntelliJ idea in java).

We're using Java so the price is a bit higher to get Intellij, but I'm still
thinking about this as a solution to improve the situation

------
woah
Try babel

~~~
andrea_sdl
this? [https://babeljs.io](https://babeljs.io)

------
zerr
The less new JS code we write the better for humanity... :)

Why don't you try TypeScript? Can be easily integrated with the existing JS
codebase.

~~~
andrea_sdl
Ahahah, I'm comfortable with JS, TypeScript and Babel might be a solution to
"hide" this, although personally I would have liked to know if there's a way
to improve the way we write plain JS.

