Questions, Round 1

5 views
Skip to first unread message

Jerold Anderson

unread,
Mar 28, 2010, 2:24:32 PM3/28/10
to base2 Group
I'm looking through the recent incantation of base2, jsb and related files.  I have questions:

Looking through the source, there is very little commenting to explain your methodology.  I get lost reading, hopping back and forth, up and down and between files.  I'm sure this makes complete sense to you, Dean, but if I am to document this properly I need to understand what's going on in your head when you write this stuff.

Can you define jsb chrome for me?

Is there some mechanism to keep people from recreating duplicate stylesheets in the DOM?

What is the difference between base2 and legacy?

Why does legacy even exist any more?

If Object.prototype is forbidden, why is is in base2?

Is "base2.DOM.bind(document);
" really necessary?  Why can't base2 or DOM do that on it's own?

Can you write a little example, using base2, dom and jsb to do the following?

  • Wire up input text, password and button elements to accept login registration information (first name, last name, email, password)
  • The name fields should be validated so the user properly enters correct capitalization
  • The email field should validate for proper email syntax
  • The password field should have the following restrictions
    • Must be 5 characters minimum
    • Must start with a letter
    • Must contain at least one digit and special character
  • Demonstrate how the registration button can be wired to send the registration information via XHR to the server
  • Also demonstrate how the validation works when the user enters data incorrectly on the form
If you can do this, I think it will help me start to wrap my head around base2 and friends.
This might be a great way for you to create examples for me too.
--
Jerold Anderson
OpenA2Z.com ~ Administrator

H: 303.719.2112
jero...@opena2z.com | jero...@stellar-sky.com

Dean Edwards

unread,
Mar 28, 2010, 3:22:47 PM3/28/10
to base...@googlegroups.com
On 28/03/2010 19:24, Jerold Anderson wrote:
> I'm looking through the recent incantation of base2, jsb and related
> files. I have questions:
>
> Looking through the source, there is very little commenting to explain
> your methodology. I get lost reading, hopping back and forth, up and
> down and between files.

There are not a lot of comments. Use the API browser to browse the
structure of the code instead. If you are not sure about something then
ask me either by email or via skype (my id is red.mullet).

> I'm sure this makes complete sense to you, Dean, but if I am to
> document this properly I need to understand what's going on in your
> head when you write this stuff.

When I write this stuff? :) The code is well structured. There is one
file per class. And all classes for a package reside in single
directory. In fact, the file structure perfectly mirrors the base2
namespace.

> Can you define jsb chrome for me?

It's not released yet. It's a JSB package to provide cross-browser UI
components; sliders, spinners, date pickers etc. It won't need much
documenting as it will just mean attaching classes to elements.

e.g.

<input class="jsb-spinner" value="50">

That will turn the <input> element into a spinner control. There is no
API to learn in order to use it so it won't need documenting.

jsb.chrome is extendible and to do this some documentation will be
required. But most people will just use it "out of the box".

> Is there some mechanism to keep people from recreating duplicate
> stylesheets in the DOM?

No. You can't stop people from doing stupid things so it's best not to
try. :)

> What is the difference between base2 and legacy?

The legacy file plugs some gaps in really ancient browsers. It was
mostly used to provide support for MSIE5.0 but I am no longer supporting
that browser in version 2 of base2.

> Why does legacy even exist any more?

It's still handy for supporting FF1. But really it is pretty redundant now.

> If Object.prototype is forbidden
> <http://dean.edwards.name/weblog/2007/03/rules/#rule2>, why is is in base2?

What do you mean? base2 does not extend any native prototypes.

> Is "base2.DOM.bind(document);" really necessary? Why can't base2 or DOM
> do that on it's own?

You may not want to bind the document. The base2.dom APIs are useful on
their own. JSB uses the base2.dom APIs without binding the document.

http://dean.edwards.name/weblog/2007/03/yet-another/
http://dean.edwards.name/weblog/2007/03/other-way/

> Can you write a little example, using base2, dom and jsb to do the
> following?
>

> * Wire up input text, password and button elements to accept login


> registration information (first name, last name, email, password)

> * The name fields should be validated so the user properly enters
> correct capitalization
> * The email field should validate for proper email syntax
> * The password field should have the following restrictions
> o Must be 5 characters minimum
> o Must start with a letter
> o Must contain at least one digit and special character
> * Demonstrate how the registration button can be wired to send the


> registration information via XHR to the server

> * Also demonstrate how the validation works when the user enters


> data incorrectly on the form
>
> If you can do this, I think it will help me start to wrap my head around
> base2 and friends.
> This might be a great way for you to create examples for me too.

OK. I'll try to knock something together this week. base2 does not have
any Ajax components though. :)

I think you should concentrate on writing test suites at first. That way
you will get to know the API slowly but surely. I'm updating the API
reference at the moment and as I pointed out before there is already
good documentation for JSB:

http://dean.edwards.name/jsb/

-dean

Jerold Anderson

unread,
Mar 29, 2010, 6:04:55 AM3/29/10
to base2-js
OK. Using your logic, I go to the API browser for base2 and I want to
add an event listener to my page. What I find in the API are five
addEventListeners. One is under DOM.Element, one is under
DOM.HTMLDocument, one is under DOM.HTMLElement, one is under
DOM.Document, and one is under DOM.EventTarget. Which one am I
supposed to use? Why are there five? The API browser is not
helpful. This is just one example, there are tons of examples.

How can one write a test suite for code that is not commented properly
and the docs that have been created are sorely lacking? I'm trying to
help here, but telling me to go and use the API browser is laughable.
That's why I've asked for a real world example of using base2 on a
registration form. Maybe then I can make sense of why you wrote the
scripts the way to did.

If I get a clear picture in my head about the structure and meaning of
the scripting I can begin to show you an easy way to document all of
your scripting. With the exception of JSB, all of the documentation,
for what has been scripted, do not help. jQuery, MooTools and many
others have documentation that can be followed and used without much
effort. This needs to be true for base2 as well. Anyone that writes
good code or scripts in this case, knows that.

And yes this is stuff, if one cannot completely understand how the
script flows and there is virtually no documentation. If the general
public try to use the base2 scripts they will make mistakes, like
creating multiple stylesheets that you called stupid. Writing code
for masses means commenting your code properly, structuring the code
so that is flows and is compartmentalized so you could have a MooTools
kind of customized builds if requested. All three of these are either
lacking or are very confusing.

Dean, you've written some excellent code, but as an advocate for
general users trying to use base2 in a real world example, base2 does
not get a passing grade.

I'm eagerly waiting to see how you create the registration page I
suggested.

:)

> http://dean.edwards.name/weblog/2007/03/yet-another/http://dean.edwards.name/weblog/2007/03/other-way/

> -dean- Hide quoted text -
>
> - Show quoted text -

Jerold Anderson

unread,
Mar 29, 2010, 6:10:37 AM3/29/10
to base2-js
One more thing. Line 48 in the base2.js file in the recent zip file.

What is: var _Object_prototype = Object.prototype?

Please explain.


On Mar 28, 1:22 pm, Dean Edwards <dean.edwa...@gmail.com> wrote:

> http://dean.edwards.name/weblog/2007/03/yet-another/http://dean.edwards.name/weblog/2007/03/other-way/

Dean Edwards

unread,
Mar 29, 2010, 6:12:14 AM3/29/10
to base...@googlegroups.com
I don't want to have a public debate like this. Thanks for your offer
to help but I will continue to write the documentation and test suite
myself.

-dean

> --
> You received this message because you are subscribed to the Google Groups "base2-js" group.
> To post to this group, send an email to base...@googlegroups.com.
> To unsubscribe from this group, send email to base2-js+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/base2-js?hl=en-GB.
>
>

Michael Hodgson

unread,
Mar 29, 2010, 6:45:07 AM3/29/10
to base...@googlegroups.com
On 29 March 2010 11:04, Jerold Anderson <jero...@stellar-sky.com> wrote:
OK. Using your logic, I go to the API browser for base2 and I want to
add an event listener to my page.  What I find in the API are five
addEventListeners.  One is under DOM.Element, one is under
DOM.HTMLDocument, one is under DOM.HTMLElement, one is under
DOM.Document, and one is under DOM.EventTarget.  Which one am I
supposed to use?  Why are there five?  The API browser is not
helpful.  This is just one example, there are tons of examples.

Well that really depends what you're trying to do, and that's going to be the answer to every one of those sorts of questions - it depends.  A "page" might be HTMLDocument, so I'd start there.  Of course in underlying code these are likely to all be exactly the same thing.  There simply isn't one single way of doing even trivial tasks in a JavaScript environment, hence it's quite right that you find multiple entries for some tasks in the API/Documentation. Thats what I love best about base2 - I can work as I want to not as Dean thinks I should.  Try using jQuery or Ext or a big library like that without working as the authors think you should and it rapidly becomes a nightmare - especially if you want to mix bits from a few libraries and the "best working practice" from each is different.
 
How can one write a test suite for code that is not commented properly
and the docs that have been created are sorely lacking?  I'm trying to
help here, but telling me to go and use the API browser is laughable.
That's why I've asked for a real world example of using base2 on a
registration form.  Maybe then I can make sense of why you wrote the
scripts the way to did.

Real world examples are great and there is no substitute for them, but I think you miss the point (as I see it) of base2.  The API, documentation and standards against which you should test are HTML5.  To quote from Deans blog base2 was to "solve various problems with inconsistent JavaScript implementations" and as I understand it the standard that is chosen for "right" is where possible HTML5?
 
If I get a clear picture in my head about the structure and meaning of
the scripting I can begin to show you an easy way to document all of
your scripting.  With the exception of JSB, all of the documentation,
for what has been scripted, do not help.  jQuery, MooTools and many
others have documentation that can be followed and used without much
effort.  This needs to be true for base2 as well.  Anyone that writes
good code or scripts in this case, knows that.

jQuery, Mootools etc. are not even trying to solve the same problem as base2.  base2 really isn't doing anything "new" and as such doesn't need much documentation.  It's fixing what's already there. New things need documentation, so the inheritance stuff (blog posts are documentation) etc. but otherwise the standard is the documentation and provides the framework for in an ideal world this is what it should do. base2 can in fact be used with no effort at all (I do so every day), just write standards compliant code and then fix the (now much fewer, thanks to base2) few problems and inconsistencies that remain.

And yes this is stuff, if one cannot completely understand how the
script flows and there is virtually no documentation.  If the general
public try to use the base2 scripts they will make mistakes, like
creating multiple stylesheets that you called stupid.  Writing code
for masses means commenting your code properly, structuring the code
so that is flows and is compartmentalized so you could have a MooTools
kind of customized builds if requested.  All three of these are either
lacking or are very confusing.

It doesn't get more compartmentalized than one class per file and a great package system?  Maybe base2 is not the library to solve the problem you have?  If MooTools is so good use it???  It's an excellent library that is all of the things you say it is.  It's just not trying to solve the same problem. It's wrong to try and have one library do everything.  A better approach is to learn enough code to stitch stuff together yourself and then pick the best tools from a suite of available libraries to do the job.  If you have faith in the "black box" that it does work, until there is a problem you simply don't need to know how it works.  Unless of course you wish to contribute to the library itself, but using the library it doesn't matter.
 
Dean, you've written some excellent code, but as an advocate for
general users trying to use base2 in a real world example, base2 does
not get a passing grade.

Forget the script kiddies who just copy examples.  The rest of the programmers out there dream of standards compliant browsers and lightweight utility classes that help to streamline our code.  base2 brings that goal closer now and I for one am thankful it exists at all.  Lightweight, standards based and fast are top of my list of priorities and today base2 is the best (and perhaps only) available for that.

-Michael

Jerold Anderson

unread,
Mar 30, 2010, 2:46:21 AM3/30/10
to base2-js
Documentation and proper testing is critical to creating any kind of
enterprise class (general public) scripting. JavaScript is not
compiled into a binary executable that runs in or with an operating
system. JavaScript is a scripting language.

I completely understand the purpose of base2 and also recognize the
fact that base2 and related scripting files have been released to the
public. Any code or script that is released to be used by the general
public should be tested and documented thoroughly. Base2 is the only
framework that does not have either proper documentation or proper
testing.

Dean asked me directly to post the conversation I was having with him
to this website for the entire group to see and now he doesn't want to
have this difficult conversation. Well, releasing code for the
general public and yet not wanting to explain it, document it or test
it properly is not responsible. I don't care how well you can write
code.

I have learned a lot from Deans work and wished to help him with this
project, but he doesn't want to have a frank conversation about the
very code he has released to be used by everyone.

Do not continue to release code or script to the general public unless
you are prepared to explain it, test it and yes, you have to defend
it.

On Mar 29, 4:45 am, Michael Hodgson <michael.hodg...@gmail.com> wrote:

Jerold Anderson

unread,
Mar 30, 2010, 2:50:57 AM3/30/10
to base2-js
Dean, please do not continue to release code or script to the public
unless you are prepared to document, test and explain all parts of
what you are trying to do.

I will continue to watch this project and your work (in general) to
see if the documentation, testing and support for your product
improve.

Good luck.

On Mar 29, 4:12 am, Dean Edwards <dean.edwa...@gmail.com> wrote:
> I don't want to have a public debate like this. Thanks for your offer
> to help but I will continue to write the documentation and test suite
> myself.
>
> -dean
>

> >>http://dean.edwards.name/weblog/2007/03/yet-another/http://dean.edwar...

> > For more options, visit this group athttp://groups.google.com/group/base2-js?hl=en-GB.- Hide quoted text -

Dean Edwards

unread,
Mar 30, 2010, 2:28:00 PM3/30/10
to base...@googlegroups.com
On 30/03/2010 07:46, Jerold Anderson wrote:
> Dean asked me directly to post the conversation I was having with him
> to this website for the entire group to see and now he doesn't want to
> have this difficult conversation.

I don't mind difficult conversations about base2. It was the tone of
your emails that I didn't like. It's possible that I am too touchy
though. :)

-dean

Pete Otaqui

unread,
Mar 30, 2010, 3:23:07 PM3/30/10
to base...@googlegroups.com
Dean,

please do continue to release awesome code, script and insight to the public.   We really appreciate the documentation you provide, the level of communication you give on this list your awesome attitude of inclusion.

The kind of interaction you had with Michael at the end of Feb in the group was fantastic, both in terms of the benefits to the one developer, and also the fact that the thinking behind your design decisions is laid out for everyone to see and learn from.

I will continue to watch this project and your work (in general) for inspiration and learning to see if my own level of understanding improves.

Good luck (and thanks!)

 

--
You received this message because you are subscribed to the Google Groups "base2-js" group.
To post to this group, send an email to base...@googlegroups.com.
To unsubscribe from this group, send email to base2-js+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/base2-js?hl=en-GB.

Reply all
Reply to author
Forward
0 new messages