<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DEMHRXozeCp7ImA9WhRWE04.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002</id><updated>2011-12-31T05:00:34.480-08:00</updated><category term="vxcore" /><category term="asp" /><category term="ruby" /><category term="yui" /><category term="mootools" /><category term="xml" /><category term="XOR" /><category term="javascript" /><category term="crockford" /><category term="arrays" /><category term="books" /><category term="programming" /><category term="DRY" /><category term="efficiency" /><category term="perl" /><category term="jQuery 1.4" /><category term="eval" /><category term="global variables are evil" /><category term="scalability of ruby on rails" /><category term="javascript libraries" /><category term="jquery" /><category term="DOM" /><category term="ruby on rails" /><category term="dojo" /><category term="sql" /><category term="douglas crockford" /><category term="rails" /><category term="optimization" /><category term="ror" /><category term="beginning javascript" /><category term="references" /><category term="JSON" /><category term="prototype" /><category term="douglas crockford is the man" /><title>Beta Test This!</title><subtitle type="html">A blog of various thoughts/ramblings/code snippets.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://matthewmaxwell.blogspot.com/" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>19</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/mybloggins" /><feedburner:info uri="mybloggins" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DUIMSH05cCp7ImA9WhdRE0Q.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-2193966103024544840</id><published>2011-08-03T11:41:00.000-07:00</published><updated>2011-08-03T11:53:09.328-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-03T11:53:09.328-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="XOR" /><category scheme="http://www.blogger.com/atom/ns#" term="arrays" /><title>Unique value in an array?</title><content type="html">So, someone recently told me about an interview question they heard about for some job at Amazon.  I thought the question and answer were neat, so I figured I'd share it.&lt;br /&gt;
&lt;br /&gt;
The question goes: "If you were given an array filled with a bunch of numbers, where every number was duplicated exactly one time except for one number, which is only in the array once, what is the most efficient way to find the unique value?"&lt;br /&gt;
&lt;br /&gt;
The answer is to iterate through the array one time, performing XOR on each of the numbers.  At the end, the value you have will be the unique value.&lt;br /&gt;
&lt;br /&gt;
Want to see it for yourself?&lt;br /&gt;
&lt;br /&gt;
Here's a JavaScript snippet I wrote to prove it on a smaller scale.  This will work on arrays of any size, however.&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
// XOR operation proof
;(function() {
 // arbitrary array of numbers
 // each number must be duplicated only once with the exception of one, unique value
 var arbitrary = [0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,19,19,20,20],
  // cache length to increase performance
  length  = arbitrary.length,
  value;
  
 // since order does not matter, iterate backwards
 // to increase performance (less operations)
 while (length--) {
  value ^= arbitrary[length];
 }

 // just incase user is trying this in IE
 // value should equal 10 (the unique value)
 if (typeof console !== "undefined") {
  console.log(value);
 }
 else {
  alert(value);
 }
}());
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
Speaking of XOR and interview questions, I was a part of creating the team test we give people who want to join our team, and one of the questions was to have the person write a piece of code that would swap variable values without using a 3rd variable as a "value bucket".  I decided to try to do this in one line using XOR, and I pulled it off.&lt;br /&gt;
&lt;br /&gt;
The JS for it is:&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
// XOR operation to swap two variables in one line of code
// only works for numeric values
;(function() {
 var a = 5,
  b = 999;
 
 // method to utilize console.log if it exists
 function log(message) {
  if (typeof console !== "undefined") {
   console.log(message);
  }
  else {
   alert(message);
  }
 }
 
 log("a: " + a + "\nb: " + b);
 
 a ^= (b ^= a ^= b) ^ a ^ b;
 
 log("a: " + a + "\nb: " + b);
}());
]]&gt;
&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-2193966103024544840?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/cv6xD3taWzXDorl2fsmA5IMVHJY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cv6xD3taWzXDorl2fsmA5IMVHJY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/cv6xD3taWzXDorl2fsmA5IMVHJY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cv6xD3taWzXDorl2fsmA5IMVHJY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/lKc7QAyGVQ0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/2193966103024544840/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2011/08/unique-value-in-array.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/2193966103024544840?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/2193966103024544840?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/lKc7QAyGVQ0/unique-value-in-array.html" title="Unique value in an array?" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2011/08/unique-value-in-array.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYBQX45eip7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-8937389178658320993</id><published>2011-08-01T23:19:00.000-07:00</published><updated>2011-08-01T23:22:30.022-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T23:22:30.022-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="dojo" /><category scheme="http://www.blogger.com/atom/ns#" term="javascript libraries" /><title>It's been a while!</title><content type="html">It truly has been a while since I have posted anything here.  To be quite honest, I have immersed myself in so much JavaScript best practices, new patterns, performance optimization, etc, that I have highly neglected this blog!&lt;br /&gt;
&lt;br /&gt;
Since my last few posts, I have increased in my JS knowledge IMMENSELY, and that is no joke.  I am w3schools certified &lt;a href="http://www.refsnesdata.no/certification/w3certified.asp?id=2788287"&gt;(link to cert)&lt;/a&gt; *with excellence*.  I got 69 of the 70 questions right! Woo hoo!&lt;br /&gt;
&lt;br /&gt;
I have studied very carefully presentations, books, papers, etc from various JS gurus, Nicholas Zakas, Douglas Crockford, John Resig, etc.  I actually printed out the current ECMAScript specification and read it on a flight to Las Vegas for a team meeting.&lt;br /&gt;
&lt;br /&gt;
I am not joking when I say this, JavaScript is one of my biggest passions.  If I could do nothing but analyze problems and engineer solutions in JavaScript all day long, I would do it!&lt;br /&gt;
&lt;br /&gt;
Unfortunately, there isn't really that great of a job market that I can find.  I don't have any degrees as of yet, and the area I live in really kind of prevents me from finding any solid JS jobs, and it'd be REALLY hard for me to relocate.&lt;br /&gt;
&lt;br /&gt;
Members on my team at work think I'm really good at JS, and I think I'm pretty good, too.  I'd like to be able to focus solely on that, as it is easily my biggest strength, but it's really hard to do that right now.&lt;br /&gt;
&lt;br /&gt;
I'll keep it as a hobby, and maybe one day, I'll find a JS engineering job to call my home.&lt;br /&gt;
&lt;br /&gt;
In other news, I am going to check out Dojo.  I've been using jQuery for a very long time now, and I'm interested to dive into another JS library.  I like what Dojo brings to the table.  I haven't had a chance to dive into the source just yet, but at face value, it promises to offer some really neat functionality.&lt;br /&gt;
&lt;br /&gt;
I am in the process of checking out the repository for the source now (it's huge).  I like to dive into source code when I'm picking something new up.&lt;br /&gt;
&lt;br /&gt;
I also purchased a book called &lt;a href="http://www.amazon.com/Mastering-Dojo-JavaScript-Experiences-Programmers/dp/1934356115"&gt;Mastering Dojo: JavaScript and Ajax Tools for Great Web Experiences&lt;/a&gt; to read over the next few days.&lt;br /&gt;
&lt;br /&gt;
I'm excited to really dig in and learn some new stuff!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-8937389178658320993?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/YbaQeiHq0-cegrKbgHELlRLoyM0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YbaQeiHq0-cegrKbgHELlRLoyM0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/YbaQeiHq0-cegrKbgHELlRLoyM0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YbaQeiHq0-cegrKbgHELlRLoyM0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/BUfi3UhuV0A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/8937389178658320993/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2011/08/its-been-while.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8937389178658320993?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8937389178658320993?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/BUfi3UhuV0A/its-been-while.html" title="It's been a while!" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2011/08/its-been-while.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkEHQXw-fSp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-3209338457573472516</id><published>2010-03-10T19:57:00.000-08:00</published><updated>2011-08-01T22:57:10.255-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T22:57:10.255-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><title>My new favorite JavaScript pattern...</title><content type="html">So, I've been doing a lot of reading, and I think I've finally come to the conclusion as to what my favorite JavaScript construction pattern is.&lt;br /&gt;
&lt;br /&gt;
And the winner is...&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
var MyObject = (function () {
 var items = [];

 /*
 Args       : index - int, index of Item
 Returns    : Item at index
 */
 function getItemByIndex(index) {
  return items[ index ];
 }

 /*
 Args       : Item - Object
 Returns    : nothing
 */
 function addItem(Item) {
  items[ items.length ] = Item;
 }

 return {
  "getItemByIndex"    : getItemByIndex,
  "addItem"           : addItem
 };
}());
]]&gt;
&lt;/script&gt;&lt;br /&gt;
I like this pattern more than this pattern:&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
(function (win, name) {
 var items = [];

 /*
 Args       : index - int, index of Item
 Returns    : Item at index
 */
 function getItemByIndex(index) {
  return items[ index ];
 }

 /*
 Args       : Item - Object
 Returns    : nothing
 */
 function addItem(Item) {
  items[ items.length ] = Item;
 }

 win[ name ] = {
  "getItemByIndex"    : getItemByIndex,
  "addItem"           : addItem
 };
}(window, "MyObject"));
]]&gt;
&lt;/script&gt;&lt;br /&gt;
The reason is because I feel like the first one is a little more easy to read.&lt;br /&gt;
&lt;br /&gt;
It just seems a little more intuitive to me.&lt;br /&gt;
&lt;br /&gt;
The conventions I use may be a little weird to you, but I'll walk you through why I have seemingly random capitalization.&lt;br /&gt;
&lt;br /&gt;
Most functions and variable names I do in camelCase:&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
getItemByIndex
addItem
]]&gt;
&lt;/script&gt;&lt;br /&gt;
I have all objects start with a capital letter.&lt;br /&gt;
&lt;br /&gt;
I know, I know -- "technically everything's an object".&lt;br /&gt;
&lt;br /&gt;
To refine my previous statement, anything that's an object literal or an object created by a constructor.&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
var Object = {};
var Object = new Object();
var Object = function () { return {}; }();
(function () { window["Object"] = {}; }());
]]&gt;
&lt;/script&gt;&lt;br /&gt;
Anything else, I do regular camelCase.&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
var items = [];
function addItem() {}
]]&gt;
&lt;/script&gt;&lt;br /&gt;
I find it allows me to recognize quickly where my objects are.&lt;br /&gt;
&lt;br /&gt;
I'd be interested in hearing about your favorite JS patterns.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-3209338457573472516?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mv09Wr6UaPk8tPIXqzUS6PRv8oI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mv09Wr6UaPk8tPIXqzUS6PRv8oI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mv09Wr6UaPk8tPIXqzUS6PRv8oI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mv09Wr6UaPk8tPIXqzUS6PRv8oI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/TRG0P3aMtcY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/3209338457573472516/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/03/my-new-favorite-javascript-pattern.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/3209338457573472516?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/3209338457573472516?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/TRG0P3aMtcY/my-new-favorite-javascript-pattern.html" title="My new favorite JavaScript pattern..." /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/03/my-new-favorite-javascript-pattern.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0QBRX0_fCp7ImA9WxBbEUg.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-3101190552826756430</id><published>2010-03-08T19:45:00.000-08:00</published><updated>2010-03-09T08:15:54.344-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-03-09T08:15:54.344-08:00</app:edited><title>New conventions at work...</title><content type="html">It doesn't take the smartest man in the world to know that without a good set of standards and best practices, a team of developers can have a real mess on their hands when it comes to project development and maintenance.&lt;br /&gt;
&lt;br /&gt;
Last weekend, I got the privilege of being the coauthor of my team's set of best practices and coding conventions.&lt;br /&gt;
&lt;br /&gt;
I am a lead JavaScript developer, so I got to write the JavaScript portion of the document.  I also contributed to the ASP and HTML/XML portions of the document as well.&lt;br /&gt;
&lt;br /&gt;
I am pretty excited about the upcoming release of our document, as it will really help push our team to the next level, and give us scalable, maintainable code.&lt;br /&gt;
&lt;br /&gt;
We've agreed to convert any page that needs edits over to the new set of standards before rerolling it to production.&lt;br /&gt;
&lt;br /&gt;
This will give us some development time increases, but in the long run, the benefit is just priceless!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-3101190552826756430?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/DBSM4r4gLMCYpSR1evhLDWOz40I/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DBSM4r4gLMCYpSR1evhLDWOz40I/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/DBSM4r4gLMCYpSR1evhLDWOz40I/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/DBSM4r4gLMCYpSR1evhLDWOz40I/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/aFT4rd3cGEI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/3101190552826756430/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/03/new-conventions-at-work.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/3101190552826756430?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/3101190552826756430?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/aFT4rd3cGEI/new-conventions-at-work.html" title="New conventions at work..." /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/03/new-conventions-at-work.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4ERnk4fSp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-8926414848347260944</id><published>2010-02-11T14:30:00.000-08:00</published><updated>2011-08-01T23:01:47.735-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T23:01:47.735-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="optimization" /><title>Optimizing your jQuery code - fragment caching rules</title><content type="html">jQuery 1.4 really introduced a lot of cool shit.  One thing in particular is the internal caching of elements.  When used properly, this can drastically increase your application's performance!&lt;br /&gt;
&lt;br /&gt;
A good example is one I'm currently doing.  Currently, I'm working on an admin page that allows a manager to go in and add/edit/remove options, details, and other data that are used by another application front-end for our tech support partners.&lt;br /&gt;
&lt;br /&gt;
I'm doing the modification via AJAX, so when they click on an option, it will grab all the details for that option, and display them, so they can be edited.  I'm caching everything grabbed and holding it locally, so I only have to do one AJAX call per option.&lt;br /&gt;
&lt;br /&gt;
When they click the edit button, I'm having the innerHTML of the cells of that row turn into input fields for them to type the new, edited data, and then save when they hit update, reverting back to a regular text-filled cell.&lt;br /&gt;
&lt;br /&gt;
As you can tell, I will be inserting a lot of inputs.&lt;br /&gt;
&lt;br /&gt;
jQuery 1.4 introduced a new way to add elements to your page.&lt;br /&gt;
&lt;br /&gt;
The old way (1.3.2) was something like&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("&lt;input type='text' id='foo' value='bar'&gt;").appendTo("#bar");
]]&gt;
&lt;/script&gt;&lt;br /&gt;
or&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("&lt;input&gt;").attr({
   "type": "text",
   "id": "foo"
});
]]&gt;
&lt;/script&gt;&lt;br /&gt;
Something like that.&lt;br /&gt;
&lt;br /&gt;
Now with jQuery 1.4, you can do&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("&lt;input&gt;", {
   "type": "text",
   "id": "foo"
});
]]&gt;
&lt;/script&gt;&lt;br /&gt;
This is similar to the second example, the object passed as the second parameter is an attribute object.&lt;br /&gt;
&lt;br /&gt;
What makes 1.4 really awesome, though is that if you use the method of $("&amp;lt;input&amp;gt;") either with an attribute object or going  $("&amp;lt;input&amp;gt;").attr(), it will cache the fragments it creates when making these.&lt;br /&gt;
&lt;br /&gt;
So, when you're adding multiple elements, you're basically getting a clone of the cached fragment, and not having to recreate an entirely new element.&lt;br /&gt;
&lt;br /&gt;
The speed and performance boost from this is crazy, and I'd definitely recommend messing around with it.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-8926414848347260944?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Lz3myrs9b8cPJLbftG9Fk78nL0U/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Lz3myrs9b8cPJLbftG9Fk78nL0U/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Lz3myrs9b8cPJLbftG9Fk78nL0U/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Lz3myrs9b8cPJLbftG9Fk78nL0U/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/WiOd46JFkig" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/8926414848347260944/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/02/optimizing-your-jquery-code.html#comment-form" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8926414848347260944?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8926414848347260944?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/WiOd46JFkig/optimizing-your-jquery-code.html" title="Optimizing your jQuery code - fragment caching rules" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>1</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/02/optimizing-your-jquery-code.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUECQ38zeyp7ImA9WxBWGEw.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-8257481768140409792</id><published>2010-02-10T08:01:00.000-08:00</published><updated>2010-02-10T08:01:02.183-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-02-10T08:01:02.183-08:00</app:edited><title>jQuery Meetups!</title><content type="html">&lt;embed wmode="opaque" src="http://static.ning.com/socialnetworkmain/widgets/index/swf/badge.swf?v=201002091145" FlashVars="backgroundColor=0xEDEDED&amp;textColor=0x797979&amp;config=http%3A%2F%2Fmeetups.jquery.com%2Fmain%2Fbadge%2FshowPlayerConfig%3Fxg_source%3Dbadge%26size%3Dmedium%26username%3D3bqupcyamvhni" width="206" height="174" bgColor="#EDEDED" scale="noscale" allowScriptAccess="always" allowFullScreen="true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer"&gt; &lt;/embed&gt;&lt;br /&gt;&lt;small&gt;&lt;a href="http://meetups.jquery.com"&gt;Visit &lt;em&gt;jQuery Meetups&lt;/em&gt;&lt;/a&gt;&lt;/small&gt;&lt;br /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-8257481768140409792?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Qu67FxlwUEr0VeOTQVK-bC-9Mm8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Qu67FxlwUEr0VeOTQVK-bC-9Mm8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Qu67FxlwUEr0VeOTQVK-bC-9Mm8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Qu67FxlwUEr0VeOTQVK-bC-9Mm8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/SvPrhXTlebY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/8257481768140409792/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/02/jquery-meetups.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8257481768140409792?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8257481768140409792?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/SvPrhXTlebY/jquery-meetups.html" title="jQuery Meetups!" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/02/jquery-meetups.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0YMSXY8cCp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-8161375556303656798</id><published>2010-01-26T15:05:00.000-08:00</published><updated>2011-08-01T23:06:28.878-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T23:06:28.878-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="beginning javascript" /><title>Ternary Operation in JavaScript</title><content type="html">Ternary operations in JavaScript are really awesome.&lt;br /&gt;
It's essentially an if/then block, but on one line.&lt;br /&gt;
&lt;br /&gt;
An example would be:&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
var x = "hello",
    y = ( x === "hello" ) ? "howdy" : "goodbye";
]]&gt;
&lt;/script&gt;&lt;br /&gt;
In this example, y would be "howdy".&lt;br /&gt;
&lt;br /&gt;
You can read ternary operations as&lt;br /&gt;
&lt;br /&gt;
y = ( comparison ) ? if it's true, use this value : otherwise, use this value ;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
This is a very simple example, but you can see the power behind this.&lt;br /&gt;
&lt;br /&gt;
An example in jQuery could be...&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("div").click(function() {
    // mutliple uses, prevents unnecessary initialization
    var div = $( this );
    div.css("background-color", div.css("background-color") === "red" ? "blue" : "red" );
});
]]&gt;
&lt;/script&gt;&lt;br /&gt;
Again, this is a very simple example, but you get the point.&lt;br /&gt;
&lt;br /&gt;
One word of advice, though: never use ternary operations if the values to be set are true/false:&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
function foo() {
    return bar === "bar" ? true: false;
}
]]&gt;
&lt;/script&gt;&lt;br /&gt;
Instead, just use the comparison:&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
function foo() {
    return bar === "bar";
}
]]&gt;
&lt;/script&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-8161375556303656798?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RpJjdeLaZZaAZscD_SU4lyGPfrA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RpJjdeLaZZaAZscD_SU4lyGPfrA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RpJjdeLaZZaAZscD_SU4lyGPfrA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RpJjdeLaZZaAZscD_SU4lyGPfrA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/7WFELarZrkU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/8161375556303656798/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/01/ternary-operation-in-javascript.html#comment-form" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8161375556303656798?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/8161375556303656798?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/7WFELarZrkU/ternary-operation-in-javascript.html" title="Ternary Operation in JavaScript" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>2</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/01/ternary-operation-in-javascript.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Dk4ARng5fip7ImA9WxBXFE4.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-1572744221271767452</id><published>2010-01-25T07:55:00.000-08:00</published><updated>2010-01-25T07:55:47.626-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-25T07:55:47.626-08:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="JSON" /><category scheme="http://www.blogger.com/atom/ns#" term="jQuery 1.4" /><title>jQuery 1.4 and native JSON support</title><content type="html">I was reading a post by Yehuda Katz (http://www.twitter.com/wycats), and saw how jQuery 1.4 now uses native JSON support, which is available in a lot of more current browsers (IE8, FF 3.5, Chrome 2), and when JSON support is not available, it falls back on its previous JSON parsing.&lt;br /&gt;
&lt;br /&gt;
In a video by Paul Irish (http://www.twitter.com/paul_irish), he states that jQuery 1.4 will now validate the JSON (if native JSON support is not available) and throw errors if the JSON response is not valid JSON, just as native JSON parse would throw errors.&lt;br /&gt;
&lt;br /&gt;
Both of these things are awesome.  I am pretty excited about that.&lt;br /&gt;
&lt;br /&gt;
I have been guilty of using malformed JSON simply because I could get away with it.&lt;br /&gt;
&lt;br /&gt;
Now, a great standard is being pushed to the forefront!&lt;br /&gt;
&lt;br /&gt;
I am going to be taking it a step further and ensure that all the JSON I use throughout my apps are valid JSON (even objects I'm passing to jQuery functions).&lt;br /&gt;
&lt;br /&gt;
I'm doing this for a few reasons.  One reason is consistency.  I like having consistent organization and standards in my applications.  This is a must at my job because different members of the team may have to go in and edit my code.  If I have a consistent style of programming, they'll be able to easily go in and make changes.&lt;br /&gt;
&lt;br /&gt;
Another reason is, it's just good practice.  If I do ALL my JSON in valid JSON format, then I won't even have to go "oh, this is an AJAX call, my response should be valid JSON", I'll just be doing ALL my JSON in valid format, and not have to worry about it.&lt;br /&gt;
&lt;br /&gt;
What are your thoughts about this?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-1572744221271767452?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/xoX7RRMIRj88UGHOTiFk31gGoKI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xoX7RRMIRj88UGHOTiFk31gGoKI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/xoX7RRMIRj88UGHOTiFk31gGoKI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/xoX7RRMIRj88UGHOTiFk31gGoKI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/12-44EGmI-k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/1572744221271767452/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/01/jquery-14-and-native-json-support.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/1572744221271767452?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/1572744221271767452?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/12-44EGmI-k/jquery-14-and-native-json-support.html" title="jQuery 1.4 and native JSON support" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/01/jquery-14-and-native-json-support.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0UBSH88fyp7ImA9WxBQFUs.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-7197477363786094210</id><published>2010-01-15T07:27:00.000-08:00</published><updated>2010-01-15T07:27:39.177-08:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2010-01-15T07:27:39.177-08:00</app:edited><title>JavaScript console</title><content type="html">At my company, I am required to support different browsers because a lot of employees here like to use their preferred browser; we support IE6+, FF2+, and Chrome.  Let me start by saying I love Chrome and I love FireFox.  They both have different aspects about them that are amazing.&lt;br /&gt;
&lt;br /&gt;
I love Chrome because it's just really good quality.  Google has never really produced any bad products to my knowledge.  They're always working to be on the cutting edge and they do a damn good job at it. The V8 engine in Chrome is fan-effing-tastic.&lt;br /&gt;
&lt;br /&gt;
Firefox is a well-rounded browser that has the ability to be customized out the ying-yang.  It's Firebug plugin is absolutely amazing.  There are also some other plugins I use that are really cool.&lt;br /&gt;
&lt;br /&gt;
One thing that make Chrome and Firefox even better is the fact that they both adhere to web standards!  What a concept, right? Haha.&lt;br /&gt;
&lt;br /&gt;
Another thing I love about them is the fact that they have a JavaScript console, which has proved to be a priceless commodity.&lt;br /&gt;
&lt;br /&gt;
IE, however, does not...unless you install something like debugbar (which is a very heavy IE plugin).&lt;br /&gt;
&lt;br /&gt;
I took some time and actually created a console (written completely in JavaScript) that works across all browsers.  I can throw different commands at the console, and even have a mode set up to take and interpret JavaScript commands.  I use this console in a newer application I'm going to release as an actual event log for my app.  It's pretty light weight, and I have added the ability for it to email my team a timestamped log of all events/responses from the application.&lt;br /&gt;
&lt;br /&gt;
I have it self-truncating at 500 rows currently, just to ensure the log doesn't get overly massive.&lt;br /&gt;
&lt;br /&gt;
I just bought my own website (www.matthewcmaxwell.com) and will be setting that up in the near future.  When I do, I'll be putting my JavaScript console up there for you to download and try out.&lt;br /&gt;
&lt;br /&gt;
Here's a small pic (bad quality, I know) &lt;img src="http://img.photobucket.com/albums/v200/leftwithoutlight/console.jpg" /&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-7197477363786094210?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sE3GUbFXWt4_TarDxZLYrYBu4L8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sE3GUbFXWt4_TarDxZLYrYBu4L8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sE3GUbFXWt4_TarDxZLYrYBu4L8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sE3GUbFXWt4_TarDxZLYrYBu4L8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/CIwRWNXSzgo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/7197477363786094210/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2010/01/javascript-console.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7197477363786094210?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7197477363786094210?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/CIwRWNXSzgo/javascript-console.html" title="JavaScript console" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2010/01/javascript-console.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CU8ARHs8fCp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-7580688686838161225</id><published>2009-12-14T10:28:00.000-08:00</published><updated>2011-08-01T22:44:05.574-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T22:44:05.574-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="eval" /><title>How I replaced eval for dynamic initialization</title><content type="html">So, I've been trying to steer clear of JavaScript eval() as much as possible ever since I learned how horribly inefficient it is.&lt;br /&gt;
&lt;br /&gt;
On a recent project I did, titled "Shark Tank", I decided to create the application on the premise that there would be one "landing" page, and the rest would all happen via AJAX.&lt;br /&gt;
&lt;br /&gt;
Well, I needed to have certain things happen on page initialization, and I try to keep my JS all in one spot at the top of the page, and not scattered throughout the page.&lt;br /&gt;
&lt;br /&gt;
So, in my links table on my database, I had the columns "FriendlyName", "URL", "Initializer"&lt;br /&gt;
&lt;br /&gt;
FriendlyName would display the friendly name, i.e. "Add a Lead", URL would be the actual url "add.asp", and the Initializer would be a string literal of the initialization function, which was housed somewhere in my namespace, i.e. "BAMPIT.Add.Initialize"&lt;br /&gt;
&lt;br /&gt;
I started off trying to figure out how to do this without eval, but ran out of time on my deadline, so I just decided to go with eval in order to get the app out on time.  Using eval on a string literal to call a function name isn't TOO bad, but I wanted to do this without eval.&lt;br /&gt;
&lt;br /&gt;
So after thinking on it for a while, I came up with a way to do it 100% dynamically, and without eval.&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: true" title="Here it is" type="syntaxhighlighter"&gt;
&lt;![CDATA[
function exec(func) {
    // func = full string literal of function,
    // i.e. Namespace.Subnamespace.Function

    var f = window;

    for (var i = 0, p = func.split("."), len = p.length; i &lt; len; i++) { // iterate through each piece of the function
        (function (i) {
            f = f[ p[i] ]; // drill down a level
        }(i));
    }

    f(); // execute the final function
}

]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
I would personally add this to a namespace or change the function name to avoid potential conflicts with anything.&lt;br /&gt;
&lt;br /&gt;
The function basically starts at the window object and drills down the namespace until it reaches the function you want to execute, and then executes the function.&lt;br /&gt;
&lt;br /&gt;
As always, criticism and comments are always welcome.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-7580688686838161225?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/P0VsBbk_jpim2s2pSGaLCYlvp3A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/P0VsBbk_jpim2s2pSGaLCYlvp3A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/P0VsBbk_jpim2s2pSGaLCYlvp3A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/P0VsBbk_jpim2s2pSGaLCYlvp3A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/wf-els2v6Xo" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/7580688686838161225/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/12/eval-replacement.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7580688686838161225?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7580688686838161225?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/wf-els2v6Xo/eval-replacement.html" title="How I replaced eval for dynamic initialization" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/12/eval-replacement.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkcARH85fCp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-7278845557256064190</id><published>2009-12-02T04:33:00.000-08:00</published><updated>2011-08-01T22:47:25.124-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T22:47:25.124-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="efficiency" /><title>JavaScript libraries are good, but be aware...</title><content type="html">So, I've been using jQuery for a while now, and I have absolutely no complaints.  Looking back at when I first began using it, my code started to get more efficient, but then I realized that, in using jQuery, I was able to do things in less typed code, but was actually adding MORE things for the browser to do.  If you're going to use a jQuery wrapped object more than once, and you're not chaining jQuery commands, save it to a variable.&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" title="Bad!" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("#tbody").css("text-align", "right");
$("#tbody").find("tr").attr("id", function (i) { return "row_" + i; });
$("#tbody").append("
&lt;tr&gt;&lt;td&gt;Stuff&lt;/td&gt;&lt;/tr&gt;
");
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
is super inefficient.  Everytime you go $("#tbody"), you're initializing a new jQuery object..&lt;br /&gt;
&lt;br /&gt;
This could be chained by going:&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" title="OK" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("#tbody").css("text-align", "right").find("tr").attr("id", function (i) { return "row_" + i; }).end().append("
&lt;tr&gt;&lt;td&gt;Stuff&lt;/td&gt;&lt;/tr&gt;
");
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
You do add an additional .end() call, which isn't as bad as the first example.&lt;br /&gt;
&lt;br /&gt;
If you didn't want to do this, you could save the initialized object to a variable:&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" title="Good!" type="syntaxhighlighter"&gt;
&lt;![CDATA[
var tbody = $("#tbody");
tbody.css("text-align", "right");
tbody.find("tr").attr("id", function (i) { return "row_" + i;});
tbody.append("
&lt;tr&gt;&lt;td&gt;Stuff&lt;/td&gt;&lt;/tr&gt;
");
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In this example, jQuery is only initialized around the tbody once.  This is a very simple example, but I think you get the point.  In a large application, CPU cycles matter!  Efficiency is key.  Building good coding habits is never a bad thing.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-7278845557256064190?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/mQ8SCiBtFLM9PdO7eWRGCFtZn0A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mQ8SCiBtFLM9PdO7eWRGCFtZn0A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/mQ8SCiBtFLM9PdO7eWRGCFtZn0A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/mQ8SCiBtFLM9PdO7eWRGCFtZn0A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/WKhrfXN12uk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/7278845557256064190/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/12/javascript-libraries-are-good-but-be.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7278845557256064190?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7278845557256064190?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/WKhrfXN12uk/javascript-libraries-are-good-but-be.html" title="JavaScript libraries are good, but be aware..." /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/12/javascript-libraries-are-good-but-be.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEUFSH45eSp7ImA9WxNQEUw.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-5332341374169850879</id><published>2009-09-16T07:43:00.000-07:00</published><updated>2009-09-16T07:43:39.021-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-16T07:43:39.021-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="douglas crockford" /><category scheme="http://www.blogger.com/atom/ns#" term="crockford" /><category scheme="http://www.blogger.com/atom/ns#" term="douglas crockford is the man" /><title>5 Reasons Why Douglas Crockford is The Man</title><content type="html">&lt;a href="http://www.crockford.com/"&gt;Douglas Crockford&lt;/a&gt;&amp;nbsp;is an amazing programmer and a really cool guy. &amp;nbsp;He's spent a very, very long time doing some really great work. &amp;nbsp;If you haven't heard of him, you need to check him out.&lt;br /&gt;
&lt;br /&gt;
I like Douglas Crockford for a few reasons.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. JSON&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Of course I had to mention it. &amp;nbsp;He made JSON into a standard and because of this, it is now a widely recognized and widely used "Data Interchange Format". &amp;nbsp;"JSON already existed in nature," is what he says, which is true, but it's his diligent work that brought it to the foreground of modern programming.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. He's&amp;nbsp;knowledgeable&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;This almost seems like a no-brainer, but he's a really smart guy. &amp;nbsp;He knows his stuff. &amp;nbsp;If you ever watch his speeches or read his documentation or books, you'll see what I'm talking about.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. He doesn't beat around the bush&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;If something sucks, he'll tell you it sucks; he doesn't sugar coat it. &amp;nbsp;I love this approach when it comes to talking about something because if you sugar coat it, the audience may miss the point entirely. &amp;nbsp;His "in-your-face" approach to how horrible most JavaScript books are is a really good example of this. &amp;nbsp;In his book "The Good Parts", he says: "If you want to learn about the bad parts and how to use them badly, consult any other JavaScript book." &amp;nbsp;Genius.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4. He's well spoken and thorough&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/b&gt;If you've ever read any of his stuff or seen him, you'll know what I mean. &amp;nbsp;He keeps on topic, he's well spoken, and thoroughly goes over every point he needs to make.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5. He responds to his email&lt;/b&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp;Ok, I know this may seem a little childish, but both times I've had questions I've asked him, he's answered within hours of receiving them, and both times, his answer has been concise and told me exactly what I needed to know. &amp;nbsp;That shows a lot of character, in my opinion.&lt;br /&gt;
&lt;br /&gt;
Often times, when people begin to work for large corporations, such as Yahoo!, they lose touch with a lot of people that respect and admire what they do. &amp;nbsp;Sometimes they just have too much work, and sometimes they just lose interest. &amp;nbsp;With Douglas Crockford, this is not the case. &amp;nbsp;He is an extremely&amp;nbsp;knowledgeable&amp;nbsp;and thorough guy, and though he may seem&amp;nbsp;cynical&amp;nbsp;at times, he's pretty friendly.&lt;br /&gt;
&lt;br /&gt;
If you haven't checked him out, do it&amp;nbsp;&lt;a href="http://www.crockford.com/"&gt;now!&lt;/a&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-5332341374169850879?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ev5m-S8v6VlASZ_0zQeRMAjKWi8/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ev5m-S8v6VlASZ_0zQeRMAjKWi8/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ev5m-S8v6VlASZ_0zQeRMAjKWi8/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ev5m-S8v6VlASZ_0zQeRMAjKWi8/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/SD61ibI6EC8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/5332341374169850879/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/5-reasons-why-douglas-crockford-is-man.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/5332341374169850879?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/5332341374169850879?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/SD61ibI6EC8/5-reasons-why-douglas-crockford-is-man.html" title="5 Reasons Why Douglas Crockford is The Man" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/5-reasons-why-douglas-crockford-is-man.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkYBQnkzeSp7ImA9WxNQEU0.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-3286022752008730484</id><published>2009-09-15T17:58:00.000-07:00</published><updated>2009-09-16T06:35:53.781-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-16T06:35:53.781-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="ruby on rails" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="scalability of ruby on rails" /><title>Scalability of Ruby on Rails</title><content type="html">I was looking through the slides from jcon today. &amp;nbsp;I really wish I could have gone; it looked like it was awesome.&lt;br /&gt;
&lt;br /&gt;
I noticed that Yehuda Katz was a speaker. &amp;nbsp;He's also a member of the Ruby on Rails core team, and I have been hearing rumors that Ruby on Rails doesn't scale well.&lt;br /&gt;
&lt;br /&gt;
That rumor is a thorn in my side because I am interested in learning Ruby on Rails, but I want to be able to use it on a potentially enterprise level...&lt;br /&gt;
&lt;br /&gt;
I sent Yehuda Katz an email, complimenting his slides and asking about the scalability of Rails and telling him that I had heard it didn't.&lt;br /&gt;
&lt;br /&gt;
He replied with the following, and I thought it would be a good idea to share, just so anyone else who is interested could add their input.&lt;br /&gt;
&lt;br /&gt;
"&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: 'times new roman';"&gt;People who say this don't really understand what scaling is. Scaling is not about the performance of the VM, it's about fundamental architecture. Rails uses the REST architecture, the same architecture used by the Internet itself. It provides strong mechanisms for both server-side and client-side caching. It's the only framework I know of to implement all of the server-side recommendations in YSlow. Rails is, in fact, a high-performance framework. If someone says Rails can't scale, ask them what exactly they mean."&lt;/span&gt;&lt;br /&gt;
&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;So, let me ask you...&lt;/span&gt;&lt;br /&gt;
&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"&gt;If you say Ruby on Rails can't scale, what DO you mean?&lt;/span&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-3286022752008730484?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/E9YyGH704C5MOtvxXUbUfqXmW-k/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E9YyGH704C5MOtvxXUbUfqXmW-k/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/E9YyGH704C5MOtvxXUbUfqXmW-k/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/E9YyGH704C5MOtvxXUbUfqXmW-k/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/w_XthKv_9FI" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/3286022752008730484/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/scalability-of-ruby-on-rails.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/3286022752008730484?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/3286022752008730484?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/w_XthKv_9FI/scalability-of-ruby-on-rails.html" title="Scalability of Ruby on Rails" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/scalability-of-ruby-on-rails.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkUNSHc6fyp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-7320309210858980878</id><published>2009-09-15T07:24:00.000-07:00</published><updated>2011-08-01T22:51:39.917-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T22:51:39.917-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="DOM" /><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><title>Sometimes the DOM IS better.</title><content type="html">I've been working with jQuery a lot lately, and, for the most part, it has never given me any issues.&lt;br /&gt;
&lt;br /&gt;
I have noticed lately, though, that when it comes to using any append/remove/find function in the jQuery library, if it is on items that have a lot of data, jQuery has serious performance issues.&lt;br /&gt;
&lt;br /&gt;
The example I ran into today was, I have a drop down that has a lot of users in it. &amp;nbsp;It's somewhere around 4,000 options.&lt;br /&gt;
&lt;br /&gt;
I normally find the selected option's text using&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
$("#select").find("option:selected").text();
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
This takes about 2 seconds or so for jQuery to do. &amp;nbsp;I believe it's because jQuery's find method isn't optimized for large traversal like that.&lt;br /&gt;
&lt;br /&gt;
I wound up making a quick jQuery extension lgtext(), which is simply:&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
jQuery.fn.extend({
        lgtext: function () {
                var that = this.get(0);
                return that.options[that.selectedIndex].text;
        }
});
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
This worked A LOT faster than jQuery. &amp;nbsp;In fact, it was pretty much an instant return.&lt;br /&gt;
&lt;br /&gt;
The jQuery appendTo method only has a few milliseconds in lag time, so I left it in. &amp;nbsp;It's enough to notice a slight pause, but not enough for it to really affect production.&lt;br /&gt;
&lt;br /&gt;
jQuery's .remove() is also very slow on this select field, taking about 2 seconds to complete as well.&lt;br /&gt;
&lt;br /&gt;
To combat this, I created my own extension, lgremove():&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: false" type="syntaxhighlighter"&gt;
&lt;![CDATA[
jQuery.fn.extend({
        lgremove: function () {
                var that = this.get(0);
                that.parentNode.removeChild(that);
        }
});
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
This works perfectly, and is also an instant completion.&lt;br /&gt;
&lt;br /&gt;
These are the only issues I've ever had with &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;, so that should say something about the library.&lt;br /&gt;
&lt;br /&gt;
It is pretty solid.&lt;br /&gt;
&lt;br /&gt;
Just to clarify, the 2 seconds of lag time was in Chrome. &amp;nbsp;I was too scared to see how many times longer it would be in IE...&lt;br /&gt;
&lt;br /&gt;
For you jQuery veterans out there, is there a better way for me to approach this using the built in jQuery methods?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-7320309210858980878?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/x_GUTqgazgHxUVBpW7DV_dEjgvQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/x_GUTqgazgHxUVBpW7DV_dEjgvQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/x_GUTqgazgHxUVBpW7DV_dEjgvQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/x_GUTqgazgHxUVBpW7DV_dEjgvQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/Bd9y8_nJ2Zk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/7320309210858980878/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/sometimes-dom-is-better.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7320309210858980878?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/7320309210858980878?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/Bd9y8_nJ2Zk/sometimes-dom-is-better.html" title="Sometimes the DOM IS better." /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/sometimes-dom-is-better.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYHQX0_eyp7ImA9WxNQEEk.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-6210846686192278853</id><published>2009-09-14T19:05:00.000-07:00</published><updated>2009-09-15T13:22:10.343-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-15T13:22:10.343-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="yui" /><category scheme="http://www.blogger.com/atom/ns#" term="jquery" /><category scheme="http://www.blogger.com/atom/ns#" term="vxcore" /><category scheme="http://www.blogger.com/atom/ns#" term="mootools" /><category scheme="http://www.blogger.com/atom/ns#" term="prototype" /><category scheme="http://www.blogger.com/atom/ns#" term="javascript libraries" /><category scheme="http://www.blogger.com/atom/ns#" term="DRY" /><title>Let's keep it DRY, folks.</title><content type="html">If there's one thing I've come to love more than anything else in programming, it's the concept of DRY (Don't Repeat Yourself).&lt;br /&gt;
&lt;br /&gt;
Seems like common sense, doesn't it? &amp;nbsp;I mean...really -- DUH!&lt;br /&gt;
&lt;br /&gt;
As common sense as it may seem, there are a lot of people out there who do repeat themselves. &amp;nbsp;In fact, I used to be one of them! &amp;nbsp;I have been spending a little extra time lately sitting down and seeing what I can functionalize because what may initially seem like added work from the tried and true copy-paste method, can actually save you a ton of time not only in later stages of development, but also in instances where you need to debug and make additions to your applications.&lt;br /&gt;
&lt;br /&gt;
Let's look at the run down on DRY coding in JavaScript and why it's useful.&lt;br /&gt;
&lt;br /&gt;
As any programmer with even a little bit of experience can tell you, requirements for projects are normally constantly changing. &amp;nbsp;It's because of this constant change that the DRY style of programming really shines. &amp;nbsp;As the criteria change, if you weren't using DRY methods of coding, you would have to make changes in multiple locations. &amp;nbsp;Keeping it DRY allows you to make a single change and be done with the modification.&lt;br /&gt;
&lt;br /&gt;
Let's face it-- everybody hates debugging.&lt;br /&gt;
&lt;br /&gt;
Imagine you're debugging an application that's a few thousand lines in code. You spend an hour or so on it and finally find the issue that's been causing it all. &amp;nbsp;You tried to call the getElementById method of documnet, which is undefined.&lt;br /&gt;
&lt;br /&gt;
Too bad you copied/pasted this functionality into about ten different places...&lt;br /&gt;
&lt;br /&gt;
Now imagine that you utilized a functionalized method in those ten places. &amp;nbsp;You find the error sooner because you're digging through less lines of code, and when you find it, you only correct it in one place and then you're done! &amp;nbsp;The same goes for making changes to that functionality. &amp;nbsp;You make the addition in one place and you're done!&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;A really good way to implement DRY programming is by creating or using pre-built JavaScript libraries.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Using a JavaScript library, you utilize reusable, functionalized code that can really decrease dev time, increase performance and make your code look a lot cleaner.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;There are some really good libraries out there.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;Some ones you may want to look into are (in no particular order):&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;a href="http://mootools.net/"&gt;MooTools&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;a href="http://developer.yahoo.com/yui/"&gt;YUI&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;a href="http://www.prototypejs.org/"&gt;Prototype&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;a href="http://code.google.com/p/vxjs/wiki/vxCore"&gt;vxCore&lt;/a&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;I use jQuery. &amp;nbsp;It was the first library I stumbled upon and it's suited my needs perfectly. &amp;nbsp;Each library has its strengths and its weaknesses, so be sure to check them all out before deciding which one to use.&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;&lt;/div&gt;&lt;div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"&gt;John Resig also wrote a very good blog about&amp;nbsp;&lt;a href="http://ejohn.org/blog/building-a-javascript-library/"&gt;Building A JavaScript Library&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
The concept of DRY can easily be adapted to any programming language. &amp;nbsp;The reason I chose to talk about it in JavaScript is because that is the language I am most familiar with, but the logic is sound in any language that can utilize functionalized code.&lt;br /&gt;
&lt;br /&gt;
Do you have any good examples of DRY programming? &amp;nbsp;All languages welcome!&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-6210846686192278853?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/YqGNBKcFhvKhfHkrecYDa8oj8m4/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YqGNBKcFhvKhfHkrecYDa8oj8m4/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/YqGNBKcFhvKhfHkrecYDa8oj8m4/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YqGNBKcFhvKhfHkrecYDa8oj8m4/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/bnxxSWzlAN4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/6210846686192278853/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/lets-keep-it-dry-folks.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/6210846686192278853?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/6210846686192278853?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/bnxxSWzlAN4/lets-keep-it-dry-folks.html" title="Let's keep it DRY, folks." /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/lets-keep-it-dry-folks.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYBQ3s5cCp7ImA9WxNQEEk.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-1248589940102438584</id><published>2009-09-14T17:26:00.000-07:00</published><updated>2009-09-15T13:22:32.528-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-15T13:22:32.528-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="ror" /><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="ruby on rails" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="books" /><title>Books I've read and approve Part 1</title><content type="html">Over the past few months, I have been completely enveloped in a new (to me) set of JavaScript conventions/ideas, and it's changed the way I program completely.&lt;br /&gt;
&lt;br /&gt;
I went from messy global variables left and right, unorganized functions, repeating myself a TON, to neater, cleaner, easier-to-read code that relies on JavaScript libraries/namespace-like functionality.&lt;br /&gt;
&lt;br /&gt;
Two books that I have read helped me make this leap, and make it a TON easier, too.&lt;br /&gt;
&lt;br /&gt;
In no particular order:&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://jspro.org/"&gt;Pro JavaScrip Techniques&lt;/a&gt;&amp;nbsp;by John Resig&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;This book was awesome. &amp;nbsp;It had a ton of information, and it taught me a lot. &amp;nbsp;I like the way Resig writes. &amp;nbsp; He doesn't really do a bunch of convoluted examples; he's pretty straight forward. &amp;nbsp;X can be accomplished Y way, but it's more efficient to do it like Z and here's why. &amp;nbsp;There were some typos here and there, but all-in-all, the book is sound. &amp;nbsp;It also comes complete with a boatload of awesome&amp;nbsp;Appendixes, one completely dedicated to Events! &amp;nbsp;Hell yes!&amp;nbsp;I would definitely recommend this to anyone, in fact, if you want to borrow it from me, hit me up!&lt;br /&gt;
&lt;br /&gt;
&lt;a href="http://oreilly.com/catalog/9780596517748/"&gt;JavaScript: The Good Parts&lt;/a&gt;&amp;nbsp;by Douglas Crockford&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;For those of you who don't know Crockford, you need to watch some of his videos; the man is hilarious. &amp;nbsp;I find him kind of cynical, but I love it. &amp;nbsp;He's not afraid to tell it like it is, whether or not you like it. &amp;nbsp;This book was pretty small, but don't let it's size fool you -- it had a lot of really awesome information. &amp;nbsp;He may seem rough around the edges, but deep down, Crockford is a man after my own heart. &amp;nbsp;He recognizes the elegance and power of JavaScript and really brings its beauty to light.&lt;br /&gt;
&lt;br /&gt;
I am all about reading awesome books about programming, so if you have any, feel free to post them here. &amp;nbsp;I am always looking for a good read.&lt;br /&gt;
&lt;br /&gt;
I think it's safe to say, JavaScript has pretty much taken over.&lt;br /&gt;
&lt;br /&gt;
I recently bought&amp;nbsp;&lt;a href="http://www.pragprog.com/titles/rails3/agile-web-development-with-rails-third-edition"&gt;Agile Web Development with Rails&lt;/a&gt;&amp;nbsp;by Sam Ruby, Dave Thomas, David Heinemeier Hansson, and I've just started it.&lt;br /&gt;
&lt;br /&gt;
I am extremely interested in how programmer-friendly RoR is.&lt;br /&gt;
&lt;br /&gt;
I would love to hear some opinions from RoR veterans.&lt;br /&gt;
&lt;br /&gt;
I know there are rumors about how it doesn't scale well, so I'd love to hear solid conversation on that aspect as well!&lt;br /&gt;
&lt;br /&gt;
Well, until next time -- have a good one!&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-1248589940102438584?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/7CmH5nSdjmrMFopjaIssXS0MseU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7CmH5nSdjmrMFopjaIssXS0MseU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/7CmH5nSdjmrMFopjaIssXS0MseU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/7CmH5nSdjmrMFopjaIssXS0MseU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/zO-aQzzPFc4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/1248589940102438584/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/books-ive-read-and-approved-part-1.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/1248589940102438584?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/1248589940102438584?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/zO-aQzzPFc4/books-ive-read-and-approved-part-1.html" title="Books I've read and approve Part 1" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/books-ive-read-and-approved-part-1.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUFRnc-eyp7ImA9WhdREks.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-762536224062936554</id><published>2009-09-14T16:51:00.000-07:00</published><updated>2011-08-01T22:33:37.953-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-08-01T22:33:37.953-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="references" /><category scheme="http://www.blogger.com/atom/ns#" term="global variables are evil" /><title>References in JavaScript</title><content type="html">So, I've been getting more refined in my usage of JavaScript, and I've stumbled across a functionality that I knew existed, but didn't know that it existed to the extent that it does, and it's really made me kind of happy.&lt;br /&gt;
&lt;br /&gt;
Since JavaScript is standard at my job, I get to use its glory in every application I create! &amp;nbsp;Woot!&lt;br /&gt;
&lt;br /&gt;
As many people know, one of JavaScripts flaws is that it's a language that is based on global variables.&lt;br /&gt;
&lt;br /&gt;
Douglas Crockford says this is evil, and I have to agree. &amp;nbsp;It gives a lot of room for libraries and plug-ins to collide with each other and make an awful mess.&lt;br /&gt;
&lt;br /&gt;
In the current portion of the project that I'm working on, I am setting up an administration page to allow people with a certain level of access the ability to completely edit call records in anyway they see fit.&lt;br /&gt;
&lt;br /&gt;
I use &lt;a href="http://jquery.com/"&gt;jQuery&lt;/a&gt;'s datepicker (with a modified theme created by &lt;a href="http://jqueryui.com/themeroller/"&gt;theme roller&lt;/a&gt;)&amp;nbsp;for the calendar (you should check it out&amp;nbsp;&lt;a href="http://docs.jquery.com/UI/Datepicker"&gt;here&lt;/a&gt;), allow the user to submit a date range and an employee to pull back call records for and then list the call records out in a nice list for them to select which one they want/need to edit.&lt;br /&gt;
&lt;br /&gt;
They then select the individual call, which is listed by Submit Date and Customer ID. &amp;nbsp;That brings them to the view/edit page.&lt;br /&gt;
&lt;br /&gt;
I pull back all the call's information via AJAX to an ASP validation page. &amp;nbsp;My ASP page formats the data in a&amp;nbsp;&lt;a href="http://json.org/"&gt;JSON&lt;/a&gt;&amp;nbsp;format, and using Douglas Crockford's&amp;nbsp;&lt;a href="http://www.json.org/json_parser.js"&gt;json_parse&lt;/a&gt;&amp;nbsp;function, I am able to parse the XML into an easy-to-use JavaScript complient JSON object.&lt;br /&gt;
&lt;br /&gt;
Neat.&lt;br /&gt;
&lt;br /&gt;
My initial thought was to create a global variable to house the call record that was currently being edited...icky...and then it hit me. &amp;nbsp;Maybe I can pass the internal object to all of my functions that edit/update, and maybe--just maybe, it will update the object, keeping all the references current, which would allow me to skate by with no additional global variables!&lt;br /&gt;
&lt;br /&gt;
So, I tested it...and it worked!&lt;br /&gt;
&lt;br /&gt;
&lt;script class="brush: javascript; collapse: true" title="Here's how I did it" type="syntaxhighlighter"&gt;
&lt;![CDATA[
function fetchCall(callId) {
    $.ajax({
        url: "callval.asp",
        type: "POST",
        data: "callId="+callId,
        dataType: "xml",
        async: true,
        global: false,
        cache: false,
        complete: function (xmlhttp) {
            var objXml = xmlhttp.responseXML, recordData = json_parse($(objXml).find("recordData").text());
            // draw out my table in a pretty modal window....
            // we'll say recordData.CustomerName = "Old Name"
            $("#editStuff").click(
                function () {
                    editStuff(recordData);
                }
            );
            $("#updateButton").click(
                function () {
                    updateRecord(recordData);
                }
            );
        }
    });
}

function editStuff(recordData) {
    // here i would draw the edit menu and have an update button
    $("#updateStuff").click(
        function () {
            // edit it accordingly
            recordData.CustomerName = $("#customerName").val();
        }
    )
}
]]&gt;
&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
I ran editStuff and then updateRecord and the new value stuck!&lt;br /&gt;
&lt;br /&gt;
Just another reason why I love JavaScript.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-762536224062936554?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/qP3i_p9WGFYQMql54k9MMK4YFgE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qP3i_p9WGFYQMql54k9MMK4YFgE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/qP3i_p9WGFYQMql54k9MMK4YFgE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/qP3i_p9WGFYQMql54k9MMK4YFgE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/JIzHTgihHbQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/762536224062936554/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/references-in-javascript.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/762536224062936554?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/762536224062936554?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/JIzHTgihHbQ/references-in-javascript.html" title="References in JavaScript" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/references-in-javascript.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEUFR38-fCp7ImA9WxNQEEk.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-4233639176026529729</id><published>2009-09-14T11:50:00.000-07:00</published><updated>2009-09-15T13:23:36.154-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-15T13:23:36.154-07:00</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="sql" /><category scheme="http://www.blogger.com/atom/ns#" term="javascript" /><category scheme="http://www.blogger.com/atom/ns#" term="xml" /><category scheme="http://www.blogger.com/atom/ns#" term="programming" /><category scheme="http://www.blogger.com/atom/ns#" term="perl" /><category scheme="http://www.blogger.com/atom/ns#" term="asp" /><title>Some reasons why I love programming (long intro)</title><content type="html">Let me preface this with the story of how I got started into programming.&lt;br /&gt;
&lt;br /&gt;
So, I started dabbling in programming probably about 6 years ago.  My friend, Zach, told me about it, and it peaked my interest.  I thought it sounded fun.  I was a little intimidated by the strict-typed object-oriented C#, so I decided I wanted to start with a scripting language that had "flexibility", so I started programming in Perl, haha.&lt;br /&gt;
&lt;br /&gt;
I loved the idea that it was super flexible, and that I could say "Do it", and Perl would usually always comply.&lt;br /&gt;
&lt;br /&gt;
I didn't use Perl too much.  I made a few hello world applications, and my biggest project was a D&amp;amp;D character roller, haha.  I eventually dropped Perl and took a break from programming.  The language just wasn't for me, but it started something that would eventually change my life.&lt;br /&gt;
&lt;br /&gt;
About 3 years later, I decided I wanted to look into programming again.  I wanted a more structured language, so that I could eventually make the move to C#.  Zach's friend Brad told me that I should check out Python.  He said it was made to be read easily, was object-oriented, and was block structured, so it would be relatively easy to pick up on.  I started messing with it, and loved it.  It was really cool.  I did a few hello world apps and then started messing with the TCL/TK widgets to create console-like applications.  It was pretty fun.&lt;br /&gt;
&lt;br /&gt;
About that time, I got a job working for my current company ( &lt;a href="http://www.clearwire.com/"&gt;Clearwire&lt;/a&gt; ).  I started as basic tech support.  When I came on board, the company was a pretty small start-up company, and didn't have a lot of tools in place.  I noticed that the process to notate a customer's account was very time consuming and not user-friendly, so I decided to make an application to help me do that.  I wrote a very simple application in Python, using TCL/TK widgets to be my GUI.  I didn't want to violate IT policy by installing Python on the machine, so at home, I used an application to compile Python into an executable and brought the executable to work with me the next day.&lt;br /&gt;
&lt;br /&gt;
I began to notice that the application actually decreased my call handle time, which was awesome.  A co-worker noticed the application and told upper management that they should check it out.  Upper management looked at it, and thought it was cool.  They even had plans to talk to IT to make the executable a standard in all the images for tech support partners.&lt;br /&gt;
&lt;br /&gt;
Around this time, there was only one programmer for all of care.  I'll call him John because I'm not sure he wants his name posted all over the internet ;P.  So, John was tasked with finding someone else to help him do the programming for care because his work load was too intensive for him to handle by himself.  The company was a start-up, so the demand on new tools was extremely high.&lt;br /&gt;
&lt;br /&gt;
John interviewed me and two other candidates.  During my interview, he asked me if I had any web application programming experience, to which I replied, "Well, I've messed around with basic HTML and CSS on my MySpace page, but other than that, no.  I've only barely dabbled in Perl and Python."  I walked out of that interview having completely bombed because I did not have the experience for what he needed.&lt;br /&gt;
&lt;br /&gt;
Later on during the day, I approached John and told him that I knew I had bombed the interview, but rather than to go on just that, he should give me a chance to prove myself.  See, I have a pretty high learning curve -- I pick up on things pretty quick, and I am able to think my way through programming logic, which is the part of programming that is the hardest, in my opinion.&lt;br /&gt;
&lt;br /&gt;
He agreed, and he said "You know that application you created to help you document the calls you take?  I want you to make that into a working web application by the end of the day."  He sent me some example code to get me started.  The basics on how to connect to a DB in ASP Classic, and a JS example on AJAX, and told me to do the rest.  He didn't care if it was super pretty; he just wanted it to work.&lt;br /&gt;
&lt;br /&gt;
I worked as hard as I could, Googling my butt off. Testing, debugging, testing, debugging, until I finally had a working application.  I even managed to have the application talk to our documentation application and have it successfully post notes to the customer's account!&lt;br /&gt;
&lt;br /&gt;
It had errors here and there, it was not efficient at all, and had a ton of overhead, but he saw the potential that I had-- I had learned enough ASP Classic, JavaScript, and SQL to make a semi-working application in less than 8 hours.&lt;br /&gt;
&lt;br /&gt;
I wound up getting moved over into the programming position, and have been doing web application development for care for about 2 and a half years now.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Well, now that you know how I got started doing what I do, let me tell you why I love programming.&lt;br /&gt;
&lt;br /&gt;
I love programming for many reasons, that would probably take me forever to type out.  This is time I just don't have, so I'll try to limit it as best I can. (These are in no particular order)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1. I love programming because it's a fast-paced environment.&lt;/b&gt;&lt;br /&gt;
It really keeps me on my toes.  As the company's needs change, so do the application's needs.  I'm never bored and always busy.  It's really fun.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2. There is a lot of awesome documentation.&lt;/b&gt;&lt;br /&gt;
There are some languages that aren't documented well, but for the most part, there is a lot of really cool and thorough documentation on languages.  I'm almost always learning to be more efficient or use better conventions/practices.  There's almost always someone out there who has done something I've done but better, and the best part is, they share it with the world!  I have a chance to learn from them and implement some of their practices in my code, which makes MY applications run better and MY users happier!&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3. The ability to express yourself in your applications.&lt;/b&gt;&lt;br /&gt;
This might be a little difficult for someone who's not a programmer to understand, but there is a level of elegance that comes with some programming.  There's a freedom of expression.  Everyone has their own particular style of coding, and it's very interesting to go through and examine different examples that they offer.&lt;br /&gt;
&lt;br /&gt;
I know the intro was long, and the reasons short, and believe me, there are way more reasons why programming is fantastic, but those are just a few of the reasons I love programming.  I'm not the best programmer by any means.  I'm still young in the community and learning more and more every day, but maybe one day I'll be the guy that people use as examples.  One can only hope!  "Our rock stars are different from your rock stars" indeed!&lt;br /&gt;
&lt;br /&gt;
I'll open this up to the floor, as well-- what are some reasons you love programming?&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-4233639176026529729?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/d7bulF2yqA4iW2Zowj8BNnfW_N0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d7bulF2yqA4iW2Zowj8BNnfW_N0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/d7bulF2yqA4iW2Zowj8BNnfW_N0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/d7bulF2yqA4iW2Zowj8BNnfW_N0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/rQKjSG4rg_w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/4233639176026529729/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/09/some-reasons-why-i-love-programming.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/4233639176026529729?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/4233639176026529729?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/rQKjSG4rg_w/some-reasons-why-i-love-programming.html" title="Some reasons why I love programming (long intro)" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/09/some-reasons-why-i-love-programming.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0ANSHkzfip7ImA9WxNRGUg.&quot;"><id>tag:blogger.com,1999:blog-1866858295468402002.post-4541561429261118741</id><published>2009-08-31T09:32:00.000-07:00</published><updated>2009-09-14T12:16:39.786-07:00</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2009-09-14T12:16:39.786-07:00</app:edited><title>Hello World!</title><content type="html">I will be using this blog to post various thoughts on programming related items, any projects I happen to be working on, as well as any code snippets I come up with that I think you may benefit from.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1866858295468402002-4541561429261118741?l=matthewmaxwell.blogspot.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/r48ZKZ6Fbmlo004nmjux_WMtnrA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r48ZKZ6Fbmlo004nmjux_WMtnrA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/r48ZKZ6Fbmlo004nmjux_WMtnrA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r48ZKZ6Fbmlo004nmjux_WMtnrA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/mybloggins/~4/3MpQJDXIoQw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://matthewmaxwell.blogspot.com/feeds/4541561429261118741/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://matthewmaxwell.blogspot.com/2009/08/upcoming-posts.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/4541561429261118741?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1866858295468402002/posts/default/4541561429261118741?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/mybloggins/~3/3MpQJDXIoQw/upcoming-posts.html" title="Hello World!" /><author><name>Matthew Maxwell</name><uri>http://www.blogger.com/profile/03101897351381022994</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="24" height="32" src="http://2.bp.blogspot.com/_cOfqtZIVzjI/ShtZIWwTQqI/AAAAAAAAAAM/OkJz0rKCldc/s1600-R/l_8a950bbdd70d60f49ef5774f013d129f.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://matthewmaxwell.blogspot.com/2009/08/upcoming-posts.html</feedburner:origLink></entry></feed>

