Better selectors for jQuery script builders

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Better selectors for jQuery script builders

Esteban A. Maringolo
Hi all,

From some time now, I want to have a consistent naming criteria for the selectors that return a JSObject or a JSFunction, and I'd like to know other ideas about naming them.

I name all the HTML rendering methods with the `renderSomething...On:`, so "render" is always the prefix and the canvas (html) the last argument (being it a single argument, or more than one).

And because of that I don't want to use 'render' as a prefix for the methods that create a script.
So lately I'm using the "create...On:" pattern for these selectors.

E.g. when you have something like:

renderContentOn: html
   html anchor
      onClick: (self createClickScriptOn: html);
      with: 'Click to toggle'.

createClickScriptOn: html
    ^(html jQuery id: 'foo') toggle


What is your criteria, if any, for this?

Regards!

Esteban A. Maringolo

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Better selectors for jQuery script builders

Philippe Marschall
On Mon, Sep 11, 2017 at 4:41 PM, Esteban A. Maringolo
<[hidden email]> wrote:
> Hi all,
>
> From some time now, I want to have a consistent naming criteria for the
> selectors that return a JSObject or a JSFunction, and I'd like to know other
> ideas about naming them.
>
> I name all the HTML rendering methods with the `renderSomething...On:`, so
> "render" is always the prefix and the canvas (html) the last argument (being
> it a single argument, or more than one).

With you so far.

> And because of that I don't want to use 'render' as a prefix for the methods
> that create a script.
> So lately I'm using the "create...On:" pattern for these selectors.

I never thought of that but it makes sense. I'm not a particular
friend of the #create selector for this. #script On: or #jQuery On:
would be other options but but I'm not in love with these as well.

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Better selectors for jQuery script builders

Esteban A. Maringolo
2017-09-11 12:52 GMT-03:00 Philippe Marschall <[hidden email]>:
> On Mon, Sep 11, 2017 at 4:41 PM, Esteban A. Maringolo
>> And because of that I don't want to use 'render' as a prefix for the methods
>> that create a script.
>> So lately I'm using the "create...On:" pattern for these selectors.
>
> I never thought of that but it makes sense. I'm not a particular
> friend of the #create selector for this.
> #script On: or #jQuery On:
> would be other options but but I'm not in love with these as well.

I don't like the jQuery prefix because it's too jQuery specific, and
hard to type :)

OTOH I'd prefer it to be a verb (like "render") and that's why I'm
moving away from the "script" prefix which I used until not so long
ago.

Also, these methods MUST return an object (JSObject), so it's not only
a render/visitor like pass, but something else.
And related with that I don't know if the preposition should be "on"
or "with" the canvas argument, usually named `html`.

The options are still open. :)

Regards,

--
Esteban A. Maringolo
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Better selectors for jQuery script builders

Johan Brichau-2

On 11 Sep 2017, at 19:14, Esteban A. Maringolo <[hidden email]> wrote:

OTOH I'd prefer it to be a verb (like "render") and that's why I'm
moving away from the "script" prefix which I used until not so long
ago.

I would say it depends a bit more on your own coding convention.

We use the scriptXXX:on: naming convention.

I never thought of it this way, but I prefer keeping that convention instead of moving to a verb, as you decided to do.
My reasoning: our script methods always return a script and do not write on the canvas, like the render methods. The canvas is passed because you need it to generate JSObject and friends, but we settled on the convention that script methods return the script the produce, and it’s only written to the canvas in a render method.

cheers
Johan

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside