473,385 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

JavaScript Editors ( Give me a text editor and a good book )

I have still yet to see a JavaScript Editor that comes close to
reading a good JS book, learing it and using it with a text editor.

Anyway, here my recipe for build successfull DHTML Applications:

If you want to support only M$ IE stop here and do the following:
1) Install blindfold
2) Repeat the phrase - I love my cage :p

Buy the Book: Buy O'Reilly's JavaScript The Definitive Guide
~ The best damn JS guide & reference period, end of story, finito

Get a good Text Editor with Syntax Highlighting support
~ Real programmers don't use WYSIWYG tools
~ You will never learn with these tools
~ Code is always inefficient
~ Apps to Use:
~ OSX - BBEdit - Powerful but no MDI support :(
~ Win32 - UltraEdit - Low cost, high power, competent
yntax Highlighting
~ ^nix - Kate or KDevelop - Well written but needs KDE (big)
~ Does not work with OSX's X11 Client :[ - ('+' key
doesn't work)

Browser Development Platform
~ Mozilla (1.3+) (FireFox release suggested)
~ Why Moz?
~ Mozilla based development works in:
~ IE 95% of the time
~ Konquorer (KDE/Apple...), Opera 99%+ of the time
~ Why not IE?
~ IE based development works in standards based
browsers only 50% of the time
~ IE black hole methods (non standards based) causes
people to ignore standards based DHTML objects,
properties and methods.
~ Browser Support Baseline
~ IE 5.5sp2+
~ This is the first (reasonably) stable
version of IE for advanced JS coding.
~ When ever I experience weird bugs from users I have them
them upgrade to IE5.5sp2+ and it goes away.
~ Netscape 6.n+
~ Netscape 4.7 should not be supported!
~ Opera ? (I plead ignorance here)
~ Konquorer/Safari ? (I plead ignorance here)

Debugging Methodology:
~ Use JS Console (Moz)
~ Put try/catches at all error prone functions / methods
~ Because of IE's error stupidity, you should get as
close to the source as possible.
~ Read stack property of error in Mozilla to
read stack of error (powerful)
~ Install JavaScript Console Status in Mozilla
~ Use window.onerror handler
~ In IE, read arguments.callee.caller... to read stack
~ Goes only to last error throw point ! not error source
point :[
~ Note: at this time, there is no way to to get to
the Error object in Mozilla from this handler.
Therefore no stack in Moz. Use Try/Catch instead

Add the following code to every page:
_w=window
function getElem(s){return document.getElementById(s)}
function getEvent(e){ return is.ie?_w.event:e }

Event Declaration
~ Avoid using inline javascript declarations (In HTML Tags)
~ Inline declarations is where you call a function or
run code from the html elements definition
(onclick="<RunSomeCode>")
~ This technique will not allow you to access
the event argument in Mozilla...
~ Instead use getElem("<Element ID>").onclick=<function name>
~ Declare handlers like:
function mySlickFunction(e){e=getEvent(e)...
~ This will ensure you always have Event Object
~ If you want to get fancy you could normalize the Event
at getEvent()
~ Method Declaration
~ Declare <obj>.<meth>=function <obj_acro>_<event>(args){
~ Example: myObj.smile=function MO_smile(args){...
~ Why? - When you build you're stack in the debug
you get the method names!

Other Stuff:
~ Use JSON (www.json.org) as much as possible to nest data
structures (for more complex programming).
~ JSON is fast (primitively supported), stable easy to read.

Could anybody else add to this list?

If people are interested, I can make a document and add other stuff
like JS debugging libraries, Consoles and other slick JS Debugging
stuff.

Happy coding!

Java (script) Dude
Jul 23 '05 #1
3 4325
On 23 Apr 2004 16:53:46 -0700, Java script Dude <de********@yahoo.ca>
wrote:

[snip]
Buy the Book: Buy O'Reilly's JavaScript The Definitive Guide
~ The best damn JS guide & reference period, end of story, finito
I personally prefer Netscape's JavaScript references and ECMA-262. I've
never bought or read a JavaScript book (and I can't say I ever intend to :)

[snip]
Debugging Methodology:
~ Use JS Console (Moz)
Opera's JavaScript console is also very helpful and automatically includes
a stack trace (although I wish "Clear" permanently cleared the list).

[snip]
Add the following code to every page:
_w=window
function getElem(s){return document.getElementById(s)}
function getEvent(e){ return is.ie?_w.event:e }
That would imply browser detection, which is a bad idea (simple
alternative below).
Event Declaration
~ Avoid using inline javascript declarations (In HTML Tags)
~ Inline declarations is where you call a function or
run code from the html elements definition
(onclick="<RunSomeCode>")
~ This technique will not allow you to access
the event argument in Mozilla...
Wrong. This isn't explained explicitly by Netscape, but there is an
example provided:

The following example uses the event object to provide the type of
event to the alert message.

<A HREF="http://home.netscape.com"
onClick='alert("Link got an event: " + event.type)'Click for link event</A>
The event object appears to be passed as an implicit argument.
~ Instead use getElem("<Element ID>").onclick=<function name>
~ Declare handlers like:
function mySlickFunction(e){e=getEvent(e)...
The same can be achieved whilst avoiding your (possible) browser detection:

e = e || window.event;
~ This will ensure you always have Event Object


So should the above, as long as all browsers follow either the Netscape or
IE event model.

[snip]

Mike

--
Michael Winter
M.******@blueyonder.co.invalid (replace ".invalid" with ".uk" to reply)
Jul 23 '05 #2
> I personally prefer Netscape's JavaScript references and ECMA-262. I've
never bought or read a JavaScript book (and I can't say I ever intend to :)
I would think that the ECMA-262 would be the best first bet from a
technical perspective. But being a technical document, it probably
would not be a good starting point for first time developers.

The O'Reilly's book is extremely well written and it's reference
structure allows for rapid resolution of syntax, objects, properties
and methods.
Debugging Methodology:
~ Use JS Console (Moz)
Opera's JavaScript console is also very helpful and automatically includes
a stack trace (although I wish "Clear" permanently cleared the list).


Now a stack dump in the console sounds sweet. Currently, I need to be
able to handle the error in moz and then dump with error.stack. If I
could have it in the console, my life would be much easier. Hmmm.
sounds like a suggestion for Moz.
[snip]
The same can be achieved whilst avoiding your (possible) browser detection:

e = e || window.event;


I stand corrected.

However, it would be a good idea to avoid putting complex JavaScript
inside of the inline handlers. It becomes difficult to read and debug
as the code gets more complex. If the handlers were put into a
separate JS file, the page size could also be reduced.

<div id="divTest" onclick="divTest_click(window.event|event)">Click
me</div>
<script>
// Handlers
function divTest_click(e){...}
...
</script>

Thanks for the input Mike!

Tim
Jul 23 '05 #3
Java script Dude wrote:
<snip>
[snip]
The same can be achieved whilst avoiding your (possible) browser
detection:

e = e || window.event;


I stand corrected.

However, it would be a good idea to avoid putting complex JavaScript
inside of the inline handlers. It becomes difficult to read and debug
as the code gets more complex. If the handlers were put into a
separate JS file, the page size could also be reduced.

<div id="divTest" onclick="divTest_click(window.event|event)">

<<snip> ^
You should be using logical OR rather than bitwise OR (which will result
in zero).

The code provided as the string values for event handling attributes is
the one place where you don't need to normalise the event object because
the implementations that provide an event object as an argument for the
internally generated event handling function use the identifier -
event - as the parameter name. So the unqualified identifier - event -
will resolve as a reference to the event parameter on browsers that pass
an event object to the function, while on browsers that have a global
event object the same identifier will be scope resolved as a property of
the global object - window.event.

So:-

onclick="divTest_click(event);"

- will pass the event object on to the - div_Test_click - function from
the event handling function in either case.

Richard.
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

22
by: Dan Rumney | last post by:
Hi all, I've been writing Javascript for quite a while now and have, of late, been writing quite a lot of AJAX and AJAX-related code. In the main, my dynamically generated pages are created...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.