Submitted by thunder3 on Sun, 03/22/2009 - 20:25
I have been thinking about when I learned an object oriented vs a procedural language. My teachers of the day (two guys who knew Java) started into the basic "this is a car" speech that I'm sure many of you had when you went to an object based language. At the time, I was confused. I could easily replicate this with a procedural based viewpoint. The thing that these teachers missed teaching me was that *objects keep their own scope*. At the time, I would have had no idea of what scope was, but I like to think that I would have learned through curiosity, rather than being stuck on Turing and its somewhat basic environment (and yes, I know that there was the OOT alternative, but we weren't that advanced yet at my backwoods highschool).
In my opinion, scope is a very important thing that is often overlooked. Minimization of scope is the coding equivalent of tidying up a room once you have left it.
Also, knowledge of linguistic scope is important to avoid unexpected consequences.
For instance:
Javascript:
function myTest(){
if(1==1){
var i = 1;
}
alert(i);
}
If you do not know i == 1 at the point of the alert, you are setting yourself up for a more probable likelihood of hard-to-debug errors. So, I personally think scope is a very important factor in learning a new language or coding style.
In Sitecore news, never try to perform a paged operation in Sitecore without a search engine index backing you up. We've tried this multiple times @ my work now, and Lucene or a similar index always performs so much better than a traditional XPath or Sitecore query that we are no longer reccomending anything else to clients.


