Commenting Your Code: Is it Just For Programmers?
From most good programmers, if you’re being taught how to program in any compiled or interpreted language, you’ll often hear the mantra Comment your code
or something similar. Why? Because good comments are worth their weight in gold. It lets others (and you when you’ve put the code away for a while) know what you are trying to accomplish with particular pieces of code. Can’t figure out what a sub-routine is doing or why it’s in there? Read the code and look for comments on it. Chances are, if the programmer had good commenting habits (even if the program your using was one of his first attempts and isn’t that great), chances are you’ll be able to quickly diagnose any problems because you’ll know what that sub-routine is supposed to be doing.
So is commenting your code just a mantra for C, C++, Perl, Ruby, Python, et al programmers? I say no. As a web developer I find websites that have even minimal comments in their code about what is supposed to go there, or why a particular structure exists, is infinitely more useful than a thousand tutorials on how to do the same thing. Conditional comments are even better. It lets you know that there is a problem with certain browsers displaying an element and shows you what the work around is. If you were to implement the work around without any head nod toward the issue (say you did it with a linked javascript, but you don’t give a reason for having it) than someone is likely to encounter the same thing and spend more time trying to reinvent the wheel instead of reusing your bit of code (or some modified version thereof; I don’t have anything to say on code reuse except to adhere to any copyright notices to original content and javascript where any such notice exists).
If at the very least you comment your code, you are allowing other web developers to learn from your own experiences without having to teach them directly and you are reminding yourself why you put that bit of code into the mix in the first place. It also allows you to remember why it’s there when you go back to edit it six months from now.
HTML obfuscation on the Internet is all but impossible. Did someone browse to your site? A copy of the page that they can open with a text editor lies in cache or Temporary Internet Files (or whatever Microsoft calls it these days). Did your page get spidered? A copy with any javascript "protection&qoute; disabled is available for viewing. So why fight against the inevitable. Even if no one else but you looks at your code, those comments can mean the difference between quick and painless updates or hours spent trying to figure out just what you were trying to do while simultaneously trying to update the site in such a way that it doesn’t completely break (I’ve done it before and I’m sure I’m not the only one).
Commenting your code isn’t just for programmers. It’s for anyone who lays down any sort of code whether it is HTML (rendered), Perl (interpreted), or C (compiled). So next time you go out and design your website, or even going back to edit an old one, don’t forget to include comments on what you are doing. Right now I’m working on a site for a client that is getting rather complex rather quick. If it weren’t for me even just commenting where certain div containers end and begin, I’d spend unnecessary time trying to find those end points. Since I started commenting from the beginning, while the page size is slightly bigger for it, I’m able to more quickly go from place to place without having to worry about closing out tags in the wrong div.
Technorati Tags: technology, computers, programming, web, html
accomplishedHowTo: Blocking Websites
Are you sick of Internet ads but don’t want to be bothered using FireFox and the Adblocker extension (which works wonderfully, by the way)? Or how about your kids going to sites which you don’t approve of? Are you using Windows (specifically XP)?
Well then I have a tip for you that will help you get a handle on what sites are loaded in your browser. For this example we are going to block Yahoo. How to block it is really simple.
First, you need to find a file simply called hosts. On most versions of Windows this should be in
C:\WINDOWS\system32\drivers\etc
The file has no extension but it’s a plain text file so you can use notepad without any problems. Once you have the file open, you should see something like this at the top:
# Copyright (c) 1993-1999 Microsoft Corp.
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
Pretty much telling you exactly how to do it with one entry defined:
127.0.0.1 localhost
You do not want to change that entry. It’s how the computer recognizes itself as home and how network services “connect” to a network without there actually being a connection to the Internet or any other network.
To block a website, Yahoo in this example, you’ll want to add another entry that looks like this:
127.0.0.1 yahoo.com
Once you restart your network connection (do it however you like), yahoo should be completely blocked.
Now this only works on the top level Yahoo domain. Any sub-domains might still be available. To block any sub-domains, you’ll have to block them one at a time following the same format.
There are programs out there that automatically generate a list of known harmful websites (pornography, sites that distribute malware, etc.) that also allows for easy editing of the hosts files. If I only had to recommend one, I would recommend Spybot – Search & Destroy. It’s free, it searches for malware on your computer (mostly software that tracks your usage of the Internet (aka spyware)), allows for the editing of your hosts file, and is free and fairly simple to use.
Of course I like doing things without having to install any software and the above mentioned method for blocking websites is by far the easiest. You don’t have to be a computer guru to edit the file, just remember the changes you’ve made. If you ever want to undo them, just delete the entry in question and restart your network connection. Another bonus is that while you have to do a little more monitoring yourself, in the end you don’t have to pay someone else to block the sites for you.
Update: One thing I failed to mention, when you save the edited file, you’ll have to delete the original and rename the file you saved from hosts.txt to just hosts, otherwise it won’t work. For some reason notepad won’t save this file without the extension. Don’t worry about the warning about removing the file extension. In this case it isn’t needed.
Technorati Tags: technology, computers
accomplishedVirigin Galactic Communicae
VIRGIN GALACTIC SIGN HISTORIC SPACEPORT AMERICA LEASE AGREEMENT – OK, who else had Mos Eisley Cantina pop into their heads when they first see that picture?
Technorati Tags: technology
amusedMemory Has Arrived
My memory has arrived and is performing well so far. Still can’t play Guild Wars, but my bro-in-law says it might be a RAM I/O problem, meaning new motherboard. Ah well. Just have to start saving up to a new computer now. I’ll keep this one running for various other stuff. I just won’t be able to play my favorite MMO.
Technorati Tags: technology, computers, hardware
accomplishedSpace and Technology – News
I found this interesting article over at Slashdot about the NOAA using a 16 year old law — the Land Remote Sensing Policy Act of 1992 — to demand that Lunar X Prize participants obtain a license (pdf) to, wait for it, take pictures of the Earth.
<sarcasm>Yeah, this was smart legislation, because you know, corporatism always works. </sarcasm> Stupid government.
In other, happier news, NASA has opened up 21 major image collections in a searchable, online database. You can find the site here. Now that is a decent use of taxpayer money (it’s at least better then using tax-dollars to murder or imprison non-violent “criminals” based upon what they choose to put in their body).
Technorati Tags: science, technology, government, news



