As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 12 years ago.
Being a C# developer, I cannot grasp why in the world one would spend time designing a perfect class in javascript, when you can't get any editor today with intellisense that will fully show you your class rules. There is only one way to maintain a well designed class in JS by documenting everything, and requiring a developer that uses the class to always refer back to its documentation.
For me - trying to become a professional javascript developer - it's so frustrating, I feel so unproductive. why is that? why can't we get an editor that will work just like C#. or maybe we would be better off if browsers starts to support a normal OOP language?
Visual Studio works quite well considering the fact that Javascript is a very dynamic language where certain functionality/fields can be added removed from an object at any moment. And Javascript isn't really OOP in a sense you know in C#. It's prototyped which is different.
Think of such an engine and you'll see that Visual Studio is doing quite well with its Javascript intellisense support.
How to enable intellisense in certain file
You have to reference other javascript files in yours to get intellisense for their functionality of course...
/// <reference path="jquery-1.4.1-vsdoc.js" />
Paths are relative to your file. This will make it possible to get intellisense for jQuery in any of your files that will have this directive right at the top of the file. References must be used to actually enable particular file's intellisense. This makes sense of course since you can have multi-faceted functions defined in various files and only one of them is used per page. Each using a different one.
Your plugins and VS JS Intellisense documentation
And when you want your code to be reused you can always add XML documentation to your code file and others will get intellisense as well while using your Javascript code file. If you don't know how to do this check the plugin on this blog post of mine and check the .toDictionary() function that has the documentation that Visual Studio is able to use for intellisense purposes.
The OOP design around javascript is more for creating a clean, maintainable, code base. You'll have seams you can use to write QUnit tests for. You can easily identify errors and rewrite code without fear of breaking stuff. You can create namespaces and closures as well. OOP is not about code completion is more about a way to write your code and not have your code written for you ;)
Related
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I'm developing Desktop-Software with different OO-based languages. I haven't got in touch with web development since recently. I just started playing around with jQuery and jQuery Mobile to build simple web applications.
I noticed that my projects usually end up with a HTML-file as a base and a *.js file which contains the methods, eventhandlers etc. This somewhat feels like programming spaghetti code and I can't think of how this could work with more complex projects. (Reusability, Performance, ...)
Usual jQuery-Tutorials are just showing trivial examples which work well with the "all methods into a single script-file"-approach. I also read somewhere, that it is better to provide just a big file because it is faster to load just one file instead of a lot small files.
Can someone tell me how bigger jQuery-projects are structured and what the reasons for that are?
I'll try to break up your question into smaller parts:
"I noticed that my projects usually end up with a HTML-file as a base and a *.js file which contains the methods, eventhandlers etc. This somewhat feels like programming spaghetti code and I can't think of how this could work with more complex projects."
Sounds like your OO background has you spoiled. Javascript won't force you to use it's prototypal inheritance, and neither will jQuery. Nevertheless, it is there. Douglas Crockford wrote a piece about moving from a classical OO-centric inheritance to the prototypal equivalent: Prototypal Inheritance in Javascript
"Usual jQuery-Tutorials are just showing trivial examples which work well with the "all methods into a single script-file"-approach."
Yes, putting all your code in one file will work fine for a small website or web-app, but it doesn't scale.
However this is no difference from putting all your C method declarations in one header and all the code in one source file. My point being that you don't have too.
I'd recommend you look at a script loader like RequireJS as a solution to this problem. In worst case there's still nothing wrong with putting your script tags inline in your HTML code but this also doesn't scale well.
"I also read somewhere, that it is better to provide just a big file because it is faster to load just one file instead of a lot small files."
Well ... yes, but this is negligible in most cases. Even if you do see a drop in performance, why treat your development code as your production? Use a compression tool such as YUI Compressor to compress and merge your JavaScript. Smaller load times without the pollution.
Final piece of advice: jQuery is not going to help you solve your JavaScript architecture problems any more than a dictionary will help you structure a sentence. (In other words, don't rely on jQuery examples to teach you good JavaScript practices).
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I know programming in general but always been doing either Delphi, VB 6 or C#.net! Now I must do web-dev and must do it fast! I haven't written a hello world in JavaScript yet and must learn jQuery because there are some charts that I must show in my web-app and looks like I must know JavaScript and jQuery to do that.
So I am looking for a jQuery resource that during its course or maybe at the first chapter gives us also a jump start on minimum JavaScript knowledge too. Some book or resource that I can hopefully sit and read through it in one day like 12 hours and after then learn enough to be able to use it and embed those darn charts and graphs into my web-app.
What do you suggest ?
The basics of Javascript as a language are actually fairly straightforward, particularly if you've got a background in several other languages as you have. You'll find it immediately familiar with curly braces and other syntax that you'll recognise from elsewhere.
If you've worked with C#, you will hopefully have been exposed to lambda functions or closures. These are very important in Javascript, where they are key for the event-driven code that drives most websites, and in particular if you're using a library like jQuery, where they are used for virtually everything. You need to get a strong handle on how these functions work if you're going to make head or tail of jQuery.
The other thing to be aware of is that Javascript's object handling works a bit differently to the other languages you's used to. There are similarities, but if you try to write your classes and objects in the way you're used to, you will get some unexpected results. See What type of language is JavaScript for more info on this.
Beyond that, I don't think you'll have a problem with the syntax.
The other thing to worry about is the DOM -- ie the browser's API which is accessed via Javascript. The DOM is not technically part of the Javascript language, but it is inextricably linked to it, and is as much part of the learning challenge as the language itself. jQuery abstracts a fair amount of the DOM away from you, but it still helps to know it.
Hope that helps get you started.
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
In Java world I always press F3 if I want to jump into a method or class, variable... anything really.
I am now working on a Javascript project and I am finding the F3 (Open Decleration) extremely limiting in Eclipse and in Aptana. Its actually almost non-existent, working only for declared variables in methods.
Our project has grown to about 50 Javascript files (~60 Javascript "objects"), and things are becoming almost unmanagable because of situations like this :
this.url = Util.buildURLFor(URLs.ticketPrefillData);
The Util object is in a file called Toolbox, and the URLs object is in a file called URLManager. The question is, how is anyone supposed to know that it is in the Toolbox file? And why can't the IDE pick out all the objects in all the files, so the F3 knows where to go.
As the javascript files grow it is becoming unmanageable (in an agile project this can be fatal) and we are thinking of switching back to Java in the form of Vaadin or ZK, unless we can find a decent intelligent IDE for code navigation.
In Summary, I need a JS IDE which can do this :
I have a method in file A which calls a method on class B1 which is in file B. It seems like no IDE i have come across can make that association.
Check out WebStorm by JetBrains. I haven't used it but have heard great things about it. It supports code navigation, and judging by ReSharper, JetBrains are really good at it.
Currently, I use Visual Studio 2012, which has great (enough, for me) navigation when you add references to your used javascript files. So in file A, when you use code in file B, you would just add this to the top of your file:
/// <reference path="./B.js" />
From now, you have Intellisense and code navigation. (VS2010 has similar features but isn't as powerful, if I recall correctly)
(your question is however kind of subjective, so might get closed/flagged; try to avoid asking questions where you ask people what they use/prefer; see the FAQ for more info)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
I occasionally write JavaScript code. I am interested in minifying it for better performance, but I don't plan to spend to much time on that, especially in testing the minified result.
I found this online service:
http://www.lotterypost.com/js-compress.aspx
So a couple questions:
Is it reliable?
Microsoft AJAX minifier vs. YUI Compressor, what's the best option?
Any other similar online tool to recommend (and why is it better than the above link)?
Google's Closure Compiler
is an excellent Javascript minifier and compiler. It analyzes the code and reports the detectable errors. It removes redundant space and unreferenced code, and renames objects to shortest possible names. You just need to compile together all Javascript files that belong to one HTML page.
That link you post happens to be the one that I use too.
Use the MS AJAX Minifer. It's way better than the yui one. besides:
http://stephenwalther.com/blog/archive/2009/10/16/using-the-new-microsoft-ajax-minifier.aspx:
The Microsoft Ajax team (I work on
this team) has been using this tool
internally for a number of years. For
example, we use the Microsoft Ajax
Minifier to minify the Microsoft Ajax
Library before publishing it.
Well if you don't trust me, run your source code (if you don't have an actual source code to test, just grab the source at http://code.jquery.com/jquery-1.6.2.js) through both and see which is more "minified".
==
Google has the Google Closure Compiler but it analyzes your code and removes unreferenced code (to furthur reduce the size of the resultant file). However usually this is not what you want because even though the functions/variables are not referenced within that file, it may be referenced from your other js files that make up your site)
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.
Closed 10 years ago.
What is the best open source/free HTML5/CSS3/JavaScript IDE?
Thank you!!!
Most of the time when I write code I am programming C# applications using Visual Studio, which is my favorite IDE. However, when it comes to Javascript VS is quite poor. It does not support collapse to definitions (AKA code folding in other IDEs / editors), does not support code outlining and also has a very primitive and most of the times useless autocomplete.
Because of that, at some point I have started to search alternative tools for JS programming and the best I came across was Aptana Studio. It also has support for HTML and CSS (as well as for some server side languages like Ruby, PHP, Phyton), but I have only used it for JS and that is an area where it shines. It has very good code outlining and one of the best autocomplete implementations I have ever seen for Javascript (even thought it is still improvable).
Aptana Studio is based Eclipse and is available as a plugin or as a full package version. On their site they are saying that the next version is going to totally independent from Eclipse, which would make it a lot more light weight and more performant. However, the current Beta version of Aptana Studio 3 is still based on Eclipse.
You can find more on Aptana Studio 3 on the official page: http://aptana.com/products/studio3
(G)Vim of course. While it might look spartanic at first, it's extremely powerful once you've become familiar with the way it works.
The answers are likely to be subjective, but here are some choices:
KompoZer
Aptana
Amaya
Here are the links: KompoZer, Aptana, Amaya.
This also may help: an extensive comparison of HTML Editors.
I use Komodo Edit. The latest version has code completion for HTML5 and CSS3, the JavaScript code completion can be adjusted depending on which JS libraries you use (eg. jQuery, prototype, YUI).
Free and open-source? - NetBeans.
There is Sublime Text 2 http://www.sublimetext.com/2 after few years with Aptana... I enjoy using it.