开发者

Firefox Extensions - best practices [closed]

开发者 https://www.devze.com 2022-12-08 20:58 出处:网络
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references,or expertise, but this question will likely solicit debate, a
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

I've been writing a Firefox extension, but have recently read a few articles explaining that it's bad practice to avoid variable name clashes by simple appending the application name to the front of the variable.

Unfortunately I have been doing this. What is the best 开发者_StackOverflow中文版practice instead? I assume it's to somehow namespace the variables. I've found various articles about wrapping everythign in a master object, but sadly no examples of this.

Can anyone point me to a good tutorial, or even a simple extension, that uses best-practices?

Thanks!


Peter Michaux explains Javascript namespacing very nicely.


You can have a look at this video from Google tech, which explains best practices for JavaScript coding which is a main part of Firefox extension development

http://www.youtube.com/watch?v=0LKDImgRfrg

alt text http://0.gvt0.com/ThumbnailServer2?app=vss&contentid=4d0ae57a8484fdf8&offsetms=275000&itag=w160&hl=en&sigh=GnGo87Drht4wi2JvP1L0PtvKT4M


Not strictly related to your original question about namespacing, but https://addons.mozilla.org/en-US/developers/docs/how-to/extension-development has a link about that as well as about other extension best practices.


Thanks very much for taking the time to answer - there's some useful stuff there for sure.

I also found this guide, which is pretty comprefensive:

http://robertnyman.com/2009/01/24/how-to-develop-a-firefox-extension/

0

精彩评论

暂无评论...
验证码 换一张
取 消