Best example of javascript pages?

O

optimistx

Which url in your opinion would be a good or even the best example of
javascript usage in a set of pages at least say 10 or more pages? How to use
css, how to split js-code to files, how to code for good
maintainability,objects, names, how to take care of older browsers, how to
optimize the coding time, etc

It might be easy to have strong opinions in the theory 'how other people
should organize their js-coding' (but I do not show mine). But who could
show an example: 'This is very good example in my opinion, and I believe I
can defend my opinion in every detail'.

A too small an example is not useful, the problems of maintainability etc
are totally different in them compared to having tens of interdependent
pages.

This far the best pages I have seen are

http://developer.yahoo.com/yui/index.html

but as a newbie programmer I would be eager to see even better examples.
Learning by looking at good examples.
 
R

Richard Cornford

optimistx said:
Which url in your opinion would be a good or even the best
example of javascript usage in a set of pages at least say
10 or more pages? How to use css, how to split js-code to
files, how to code for good maintainability,objects, names,
how to take care of older browsers, how to optimize the
coding time, etc

Aren't you pre-supposing the validity of the notion that for javascript
there is a generally applicable "best"? It strikes me as much more
likely that the context for which scripts are written should guide the
design criteria. So while writing for the public Internet genuinely
cross-browser code with fully planed out clean degradation to a viable
underlying system may be the best that can be achieved, while when
writing for an Intranet neither of cross-browser code nor clean
degradation may be applicable issues at all. A large e-commerce site may
suggest designing and building what is effectively an OO application
framework with javascript, while for a small site presenting essentially
static information doing that would be ridiculously over the top and
inappropriate.

A too small an example is not useful, the problems of
maintainability etc are totally different in them compared
to having tens of interdependent pages.

You are probably wrong there. There may be a tendency for unmaintainable
code to be exponentially more of a pain to work with the more of that
code there is but that does not excuse writing small systems that are
unmaintainable.
This far the best pages I have seen are

http://developer.yahoo.com/yui/index.html

A page that commences with the words "The Yahoo! User Interface Library
is a set of utilities and controls, written in JavaScript, for building
richly interactive web applications using techniques such as DOM
scripting, HTML and AJAX", so if you are not building "richly
interactive web applications" even Yahoo may question the
appropriateness of their code.
but as a newbie programmer I would be eager to see even
better examples. Learning by looking at good examples.

Looking won't necessarily help unless you can get access to the
reasoning behind the design decisions made in the creation of such code.

Richard.
 
M

Matt Kruse

optimistx said:
Which url in your opinion would be a good or even the best example of
javascript usage in a set of pages at least say 10 or more pages?

There are many different theories on how javascript should be used, so
reaching a concensus on 'best' would be impossible. You should look at
several different approaches, styles, and techniques, and hopefully learn
enough to decide for yourself which approach you think best matches your
needs.

My Javascript site is http://www.JavascriptToolbox.com which, I think, shows
a number of good designs and practices. It surely also has some cons. Nobody
is perfect, especially when working on sites at 1:00am after the wife and
kids are asleep ;)
How to use css, how to split js-code to files, how to code for good
maintainability,objects, names, how to take care of older browsers, how
to
optimize the coding time, etc

One thing to keep in mind: If everything could be broken down into clear and
simple instructions to do things in the "best way" then there wouldn't be
much need for programmers. It would be trivial to wite code generators to do
all the work. The reality is, development is far too complex and there are
too many factors to consider to make a single approach the law which should
be applied in all situations.

I have a "best practices" document for Javascript which I plan to expand
soon to be a little more accurate and clear, and also to cover some of the
questions you seem to be asking:
http://www.JavascriptToolbox.com/bestpractices/

You are welcome to ask me questions (here) about any specific decisions or
approaches taken on my site(s). Discussions on topics like these can be very
helpful to many.
 
O

optimistx

Aren't you pre-supposing the validity of the notion that for javascript
there is a generally applicable "best"?

In one's _opinion_ the best. Like 'I would like to be able to write
systems like that'.
It strikes me as much more
likely that the context for which scripts are written should guide the
design criteria.

ok, a little more specific wish list.
Let us look at only publicly available sites, not intranets, not simple
'Hello world'-type of sites.
Sets of pages, which could perhaps be constructed by some manmonths of
effort, not some hours or few days.
You are probably wrong there. There may be a tendency for unmaintainable
code to be exponentially more of a pain to work with the more of that
code there is but that does not excuse writing small systems that are
unmaintainable.

Of course one should try to write as modular systems as possible.
Looking won't necessarily help unless you can get access to the
reasoning behind the design decisions made in the creation of such code.

So, if I want to get a Nobel Prize in literature and want to read good books
first before writing my own, there are no good books? :)

But thanks anyway for your opinions.
 
R

Richard Cornford

optimistx said:
Richard Cornford wrote:

ok, a little more specific wish list.
Let us look at only publicly available sites, not intranets,
not simple 'Hello world'-type of sites.

Excluding only the trivial does not do much to narrow the criteria. But
my point was that the thing that is useful to learn is not how to create
code of any particular single situation but instead how to choose
appropriate design criteria and implementation strategies for whatever
situation that comes along.
Sets of pages, which could perhaps be constructed by some
manmonths of effort, not some hours or few days.

When some people can do in hours what others would take months over that
doesn't really mean much.

So, if I want to get a Nobel Prize in literature and want
to read good books first before writing my own, there are
no good books? :)
<snip>

Literature is art, you need talent for that. Would you win the prize for
physics only observing good examples of the physical, or would
understanding the current theory, and the though process behind it,
help?

Richard.
 
O

optimistx

"Matt Kruse" <[email protected]> kirjoitti viestissä
....
My Javascript site is http://www.JavascriptToolbox.com which, I think, shows
a number of good designs and practices. It surely also has some cons. Nobody
is perfect, especially when working on sites at 1:00am after the wife and
kids are asleep ;)

Thanks for your valuable link. I have been studying them already several
weeks ago. Their contents, especially the words 'best practices' partly
made me start this thread. Your pages are an valuable example for me, and I
became interested in seeing other examples. Reading one good book makes one
eager to read more.
....
The reality is, development is far too complex and there are
too many factors to consider to make a single approach the law which should
be applied in all situations.

We agree. There are many good styles and selecting one is a matter of
opinion. We might say '_in my opinion_ this code is thus far the best, and
I wish I could write code like this'. I am interested in opinions, not the
one and only truth.

The creator of PHP wrote a simple example of the code he thought was good.:

http://toys.lerdorf.com/archives/38-The-no-framework-PHP-MVC-framework.html

The discussion was heated but very useful and educational. I thought people
would dare to stick out their head here too :). You did, and I appreciate
that . An example need not be one's own pages, of course..
 
R

Randy Webb

optimistx said the following on 4/24/2006 4:44 AM:
"Matt Kruse" <[email protected]> kirjoitti viestissä
....

Thanks for your valuable link. I have been studying them already several
weeks ago. Their contents, especially the words 'best practices' partly
made me start this thread. Your pages are an valuable example for me, and I
became interested in seeing other examples. Reading one good book makes one
eager to read more.

And what you have seen in this thread so far should point out the fact
that what one considers a good book may not be a good book to another.
The same goes with scripting. And, as Richard pointed out, what
qualifies as a "good solution" depends - directly - on the problem being
solved.

We agree. There are many good styles and selecting one is a matter of
opinion. We might say '_in my opinion_ this code is thus far the best, and
I wish I could write code like this'. I am interested in opinions, not the
one and only truth.

There is no "one and only truth", there are only opinions when it comes
to coding style. There are one and only truths when you get to
particular problems and particular solutions.
 
R

Richard Cornford

optimistx wrote:
... . I thought people would dare to stick out their head
here too :). ...
<snip>

Having made a post announcing your support for people wasting the time
of the contributors to this group (by encouraging them not to
familiarise themselves with the FAQ) is it really surprising that there
are not many left willing to expend time on you?

Richard.
 
O

optimistx

Richard Cornford wrote:
....
Having made a post announcing your support for people wasting the time
of the contributors to this group (by encouraging them not to
familiarise themselves with the FAQ) is it really surprising that
there are not many left willing to expend time on you?
....
Good question :).

I stated the obvious fact that if people are supposed to spend many hours of
their time before their first posting, then many of them do not spend.

A cure would be to have a condensed short part of FAQ, which would list the
absolute minimim requirements for an acceptable post. Those minimum
requirements would be presented here once every day or so. If a person
presents a question breaking those requirements the old experienced
js-experts could leave the post unanswered, instead of writing detailed,
conscise, unfriendly harsh remarks. 'You break our rules, go away'.

The more the js-experts spend their time here the more frustrated they get
during the years. The reason is simple: the portion of problems which are
interesting, educational and enough high quality for their own personal
developement goes asymptotically towards zero. Have you noticed that?

If the overall quality of the groups needs to be advanced, why not make a
new group 'advanced javascript' or 'newbie javascript'?

I have not felt similar irritation, annoyment, unfriendliness e.g. in
comp.lang.php, which might have higher volume of traffic compared to
this.comp. lang.javascript

Of course many people here are polite, friendly, symphatetic. But even a few
exceptions creates an uncomfortable atmosphere.
 
R

Richard Cornford

optimistx said:
Richard Cornford wrote:
...
...
Good question :).

I stated the obvious fact that if people are supposed to spend
many hours of their time before their first posting, then many
of them do not spend.

Observing that people may not always do what they should do was not all
you did, you also implied that their behaviour should be acceptable, and
so be consequence-free. As it is not you will have done harm to anyone
who takes you seriously and indeed those who choose to do as they
should, as the time needlessly squandered by the others will not be
available to the deserving.
A cure would be to have a condensed short part of FAQ, which
would list the absolute minimim requirements for an acceptable
post.

You haven't actually read the FAQ, have you? But in any event, a
formulation of words that sufficiently concisely explains the situation
is difficult to devise, and people are more likely to follow conventions
and advice when they understand why, which takes explanation and so
consequently time to study that explanation.

... . If a person presents a question breaking those requirements
the old experienced js-experts could leave the post unanswered,
instead of writing detailed, conscise, unfriendly harsh remarks.
'You break our rules, go away'.

Precisely how many people have you seen telling others to go away? One
or two at best, and it is a meaningless proposal as this is an
unmediated, publicly accessible group. The most prevalent reaction to
recalcitrant disregarders of the conventions is to silently ignore them,
and you see plenty of evidence of that where top-posters and those who
will not quote appropriately are left to suffer each other's dubious
advice. And indeed here, where a subject that has resulted in worthwhile
debate in the past is passed over by at least half a dozen with
well-formed and interesting opinions on the subject.
The more the js-experts spend their time here the more
frustrated they get during the years. The reason is simple:
the portion of problems which are interesting, educational
and enough high quality for their own personal developement
goes asymptotically towards zero. Have you noticed that?

Not at all, the people who were trying to be interested and helpful when
they started posting to the group still seem just as keen to be
interested and helpful now, they (with the obvious exception) just tend
to be more knowledgeable and experienced now. The only apparent sources
of frustration are the number of times it is necessary to repeat the
same advice; such as explaining to people why "it doesn't work" is not
much good as an error report. It makes you wish someone would write
these things down and put them on the Internet so that it was not
necessary to repeat them ad infinitum, but that only saves everyone
effort if you can get people to go and read the material they are
referred to.
If the overall quality of the groups needs to be advanced,
why not make a new group 'advanced javascript' or 'newbie
javascript'?

And how is that supposed to work? A group of people who don't really
know what they are doing just talking to each other. That is hardly
going to help much, all that would do is propagate the "this 'works' for
me" code that is already at the root of a significant proportion of the
problems posted here. And what happens if a loony like VK gets in among
them and posts something like:-

<quote
cite="
<script type="text/javascript">
void function dummy(args) {
alert('Booh!');
}

window.onload = dummy;

....

Function dummy is being parsed and allocated on script load,
but void operator prevents the script context to get a reference
on the allocated memory heap. So it becomes garbage collector
ready right away.
</quote>

- and there is nobody around who understands javascript well enough to
point out that it is total fantasy? Might it not be believed,
propagated, be integrated into a consistent but otherwise fantastic
conception of the language (added to with more contributions from the
same source)? Isn't the result going to be that everyone involved ends
up knowing less of javascript as time goes by (because knowing that you
don't know something is knowing more than believing that you know
something that is false)?
I have not felt similar irritation, annoyment, unfriendliness
e.g. in comp.lang.php, which might have higher volume of traffic
compared to this.comp. lang.javascript

Where "I have not felt ..." is significant; these are your perceptions,
not necessarily the reality.
Of course many people here are polite, friendly, symphatetic.

And you would have people needlessly waste their time regardless.
But even a few exceptions creates an uncomfortable atmosphere.

People cannot easily be prevented form posting to Usenet. But your
perception of the behaviour of one or two individuals does not alter the
benefit that posters will derive from reading the FAQ, they are
unrelated issues.

Richard.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top