<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: utility code in toolkit</title>
	<atom:link href="http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/feed/" rel="self" type="application/rss+xml" />
	<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/</link>
	<description>Fun and games with the politics of open source</description>
	<lastBuildDate>Fri, 24 Feb 2012 22:59:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
	<item>
		<title>By: Davide Ficano</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-703</link>
		<dc:creator>Davide Ficano</dc:creator>
		<pubDate>Sun, 06 Nov 2005 08:17:32 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-703</guid>
		<description>The idea is great, in my extensions always I have a js module called XXXCommon which contains reusable code.
But there are some problems:
1. Namespace must be guaranteed due to possible version signature problems, consider a version may clash with superior revision, oh yes this is always possible :-)
I wrap common functions in &quot;namespace&quot; prefixed with extension name but this is bad practice for real reusable code.
2. Modules must be considered snippets of code instead of real library, I prefer to &quot;import&quot; only functions I really use instead of tons of unused routines.
I hate JSLib because is too big
I have my access file functions without using JSLib , I have Url access function and many specific functions</description>
		<content:encoded><![CDATA[<p>The idea is great, in my extensions always I have a js module called XXXCommon which contains reusable code.<br />
But there are some problems:<br />
1. Namespace must be guaranteed due to possible version signature problems, consider a version may clash with superior revision, oh yes this is always possible <img src='http://snarkfest.net/blog/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /><br />
I wrap common functions in &#8220;namespace&#8221; prefixed with extension name but this is bad practice for real reusable code.<br />
2. Modules must be considered snippets of code instead of real library, I prefer to &#8220;import&#8221; only functions I really use instead of tons of unused routines.<br />
I hate JSLib because is too big<br />
I have my access file functions without using JSLib , I have Url access function and many specific functions</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Basson</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-702</link>
		<dc:creator>Ben Basson</dc:creator>
		<pubDate>Thu, 03 Nov 2005 19:00:53 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-702</guid>
		<description>Hi Mike, thanks for the reply (and obviously thanks for doing this!)...

I was referring to functions like getSpecialFolderKey(aFolderType), of which there may be similar instances. These are functions declared inside other functions and cannot usually be directly accessed.

Perhaps what I meant to say was &quot;no functions inside functions&quot; instead... that would probably be a lot more constructive ;)</description>
		<content:encoded><![CDATA[<p>Hi Mike, thanks for the reply (and obviously thanks for doing this!)&#8230;</p>
<p>I was referring to functions like getSpecialFolderKey(aFolderType), of which there may be similar instances. These are functions declared inside other functions and cannot usually be directly accessed.</p>
<p>Perhaps what I meant to say was &#8220;no functions inside functions&#8221; instead&#8230; that would probably be a lot more constructive <img src='http://snarkfest.net/blog/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ted Mielczarek</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-701</link>
		<dc:creator>Ted Mielczarek</dc:creator>
		<pubDate>Thu, 03 Nov 2005 18:39:03 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-701</guid>
		<description>Finally, giving some love to the extension authors.  Let me know if you want any help on this!</description>
		<content:encoded><![CDATA[<p>Finally, giving some love to the extension authors.  Let me know if you want any help on this!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mike</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-700</link>
		<dc:creator>Mike</dc:creator>
		<pubDate>Thu, 03 Nov 2005 16:52:39 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-700</guid>
		<description>Christian:

getPref is based on the implementation in inspector, and checks the pref type and uses the right method.  It also definitely has that optional param for a default value.

Ben:

I&#039;m not sure I understand the comments about OS-specific ifdefs.  In some cases we have things that aren&#039;t implemented (i.e. nsILocalFile) where we need to do hackarounds for that platform.  As long as extension authors can call foo(argA, argB) on any platform and get a reasonable and expected action, I don&#039;t think it matters what the underlying implementation looks like, and whether its preprocessed.</description>
		<content:encoded><![CDATA[<p>Christian:</p>
<p>getPref is based on the implementation in inspector, and checks the pref type and uses the right method.  It also definitely has that optional param for a default value.</p>
<p>Ben:</p>
<p>I&#8217;m not sure I understand the comments about OS-specific ifdefs.  In some cases we have things that aren&#8217;t implemented (i.e. nsILocalFile) where we need to do hackarounds for that platform.  As long as extension authors can call foo(argA, argB) on any platform and get a reasonable and expected action, I don&#8217;t think it matters what the underlying implementation looks like, and whether its preprocessed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Jed</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-699</link>
		<dc:creator>Jed</dc:creator>
		<pubDate>Thu, 03 Nov 2005 16:15:20 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-699</guid>
		<description>Awesome.
Thank you for taking the time to do this, it will help extension authors greatly!

If you need help documenting what you do, please hollar as documentation on what utilities are available will be crucial.

Also, for file access, there is a great IO lib you could look into:
http://kb.mozillazine.org/Io.js

Cheers
-Jed</description>
		<content:encoded><![CDATA[<p>Awesome.<br />
Thank you for taking the time to do this, it will help extension authors greatly!</p>
<p>If you need help documenting what you do, please hollar as documentation on what utilities are available will be crucial.</p>
<p>Also, for file access, there is a great IO lib you could look into:<br />
<a href="http://kb.mozillazine.org/Io.js" rel="nofollow">http://kb.mozillazine.org/Io.js</a></p>
<p>Cheers<br />
-Jed</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Christian Weiske</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-698</link>
		<dc:creator>Christian Weiske</dc:creator>
		<pubDate>Thu, 03 Nov 2005 15:55:34 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-698</guid>
		<description>getPref() should take an optional parameter for the default value in case the key doesn&#039;t exist.
And either there are multiple functions as getIntPref(), getBooleanPref() and getStringPref(), or the one getPref() function should switch according to the type.</description>
		<content:encoded><![CDATA[<p>getPref() should take an optional parameter for the default value in case the key doesn&#8217;t exist.<br />
And either there are multiple functions as getIntPref(), getBooleanPref() and getStringPref(), or the one getPref() function should switch according to the type.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Henrik Gemal</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-697</link>
		<dc:creator>Henrik Gemal</dc:creator>
		<pubDate>Thu, 03 Nov 2005 15:54:51 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-697</guid>
		<description>- Getting th URL of the current loaded document would be a nice thing.

- Opening a URL would also. Trying to do that so that  it works in both Firefox and Thunderbird is a pain.</description>
		<content:encoded><![CDATA[<p>- Getting th URL of the current loaded document would be a nice thing.</p>
<p>- Opening a URL would also. Trying to do that so that  it works in both Firefox and Thunderbird is a pain.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ben Basson</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-696</link>
		<dc:creator>Ben Basson</dc:creator>
		<pubDate>Thu, 03 Nov 2005 15:36:45 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-696</guid>
		<description>Ok, as promised - here&#039;s some more things that I&#039;d love to see addressed.

1) promptService.confirmEx is possibly the worst interface I&#039;ve ever had to use. Multiplication is required to set the button order, which is also not what you&#039;d expect it to be at all. What&#039;s really needed is a JavaScript function which totally masks confirmEx.

Ideally, this function would accept a title, some body text and an array containing two or more strings (for button labels) in the order that they are to be displayed and returns the clicked button (i.e. corresponding to the array element passed).

Example:

var buttonClicked = confirmEx(&quot;Do you want to use confirmEx?&quot;,&quot;Please click one of the buttons...&quot;,[&quot;Yes&quot;,&quot;No&quot;,&quot;Maybe&quot;]).

2) Lots of functions in Firefox are relatively inflexible. For example, most things that call File pickers specify a default directory inline. To use the native filepicker functionality, but also specify my own default, I have a choice of overlaying a key function and then flipping the process when I&#039;m done, or duplicating the code, only to have it break (or be different) later.

It would be really nice to have some load and save functions functions that don&#039;t rely on inline values, so we can simply use a function with a prototype similar to:

function saveFile (aInput, aDefaultDir, aReferrer, aBypassFilePicker, aOverwrite, aTitle, aFilters);

Where:

i) aInput is a nsIFile, nsILocalFile or nsIURI
ii) aDefaultDir is a nsILocalFile or a pref string to convert to an nsILocalFile
iii) aReferrer is an optional nsIURI
iv) aBypassFilePicker is a boolean value to show or not show the file picker during the save process
v) aOverwrite is a boolean value to specify whether files should be overwritten (or the filename incremented) when saving without the filepicker
vi) aTitle is an optional string value for the title of the file picker
vii) aFilters is an array of filters to apply to the filepicker

3) The aggressive removal of any OS-specific ifdefs, to be replaced with code that simply gives authors what they want in each case would be wonderful.</description>
		<content:encoded><![CDATA[<p>Ok, as promised &#8211; here&#8217;s some more things that I&#8217;d love to see addressed.</p>
<p>1) promptService.confirmEx is possibly the worst interface I&#8217;ve ever had to use. Multiplication is required to set the button order, which is also not what you&#8217;d expect it to be at all. What&#8217;s really needed is a JavaScript function which totally masks confirmEx.</p>
<p>Ideally, this function would accept a title, some body text and an array containing two or more strings (for button labels) in the order that they are to be displayed and returns the clicked button (i.e. corresponding to the array element passed).</p>
<p>Example:</p>
<p>var buttonClicked = confirmEx(&#8220;Do you want to use confirmEx?&#8221;,&#8221;Please click one of the buttons&#8230;&#8221;,["Yes","No","Maybe"]).</p>
<p>2) Lots of functions in Firefox are relatively inflexible. For example, most things that call File pickers specify a default directory inline. To use the native filepicker functionality, but also specify my own default, I have a choice of overlaying a key function and then flipping the process when I&#8217;m done, or duplicating the code, only to have it break (or be different) later.</p>
<p>It would be really nice to have some load and save functions functions that don&#8217;t rely on inline values, so we can simply use a function with a prototype similar to:</p>
<p>function saveFile (aInput, aDefaultDir, aReferrer, aBypassFilePicker, aOverwrite, aTitle, aFilters);</p>
<p>Where:</p>
<p>i) aInput is a nsIFile, nsILocalFile or nsIURI<br />
ii) aDefaultDir is a nsILocalFile or a pref string to convert to an nsILocalFile<br />
iii) aReferrer is an optional nsIURI<br />
iv) aBypassFilePicker is a boolean value to show or not show the file picker during the save process<br />
v) aOverwrite is a boolean value to specify whether files should be overwritten (or the filename incremented) when saving without the filepicker<br />
vi) aTitle is an optional string value for the title of the file picker<br />
vii) aFilters is an array of filters to apply to the filepicker</p>
<p>3) The aggressive removal of any OS-specific ifdefs, to be replaced with code that simply gives authors what they want in each case would be wonderful.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gemal's Psyched Blog</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-695</link>
		<dc:creator>Gemal's Psyched Blog</dc:creator>
		<pubDate>Thu, 03 Nov 2005 15:27:02 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-695</guid>
		<description>&lt;strong&gt;Utility functions for extensions in toolkit&lt;/strong&gt;

Basically, my plan is to create a set of generic toolkit files to act as wrappers for commonly used functions, in order to facilitate simpler and more future-proof app and extension code. Read more This is want I&#039;ve been requesting...</description>
		<content:encoded><![CDATA[<p><strong>Utility functions for extensions in toolkit</strong></p>
<p>Basically, my plan is to create a set of generic toolkit files to act as wrappers for commonly used functions, in order to facilitate simpler and more future-proof app and extension code. Read more This is want I&#8217;ve been requesting&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Robert Accettura</title>
		<link>http://snarkfest.net/blog/2005/11/03/utility-code-in-toolkit/comment-page-1/#comment-694</link>
		<dc:creator>Robert Accettura</dc:creator>
		<pubDate>Thu, 03 Nov 2005 14:50:30 +0000</pubDate>
		<guid isPermaLink="false">http://steelgryphon.com/blog/?p=64#comment-694</guid>
		<description>I&#039;m loving the idea.

IMHO on the same page, something like jslib should be included in firefox.  Would save tons of time if we had that.  Lots of extensions rely on it anyway.  Solves lots of I/O and other complexity issues.</description>
		<content:encoded><![CDATA[<p>I&#8217;m loving the idea.</p>
<p>IMHO on the same page, something like jslib should be included in firefox.  Would save tons of time if we had that.  Lots of extensions rely on it anyway.  Solves lots of I/O and other complexity issues.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

