Saturday, November 26, 2011

Hungarian Notation - You Should Reconsider It

I used to think that Hungarian Notation was silly. I had a hard time seeing the point of it, and it just seemed like visual clutter when reading code. Eventually, I ended up working on a team that used it, and it really grew on me! The real problem with Hungarian Notation is that it comes in so many different forms. So, its effectiveness can vary, and the perception of it can vary as well, from highly useful to friggin’ annoying. But the benefits of a consistent naming convention shouldn’t be written off just because there are some less-than-ideal examples out there. The truth is, it’s pretty useful, and it can save you a lot of grief.

Wednesday, November 16, 2011

Add to the Java Classpath at Runtime

When writing an application, in any programming language, one often needs to load data from an external resource. This is typically a file on the filesystem, in which case one writes code to open the file using a filesystem path, and read the contents. The Java programming language lets you do this in a more abstract way, where instead of loading a file, or a device, you simply load a “resource”.

Monday, November 14, 2011

Java: getResource() vs. getResource() ...er, huh?

The 'getResource' method in Java allows applications to get files and other resources generically, without hard-coded knowledge of the type of resource, as long as it's in your class path. The only caveat is that you make sure you understand the difference between the getResource method and the other method used for the same purpose called 'getResource'.

Er... wait. Huh? Is that right?

Unfortunately, yes.

Friday, November 11, 2011

Droj's Javascript Evaluator Tool

When learning Javascript, one of the most valuable tools you can have is a way to run snippets of code on the fly, without editing a file, then saving it, then reloading the page in your browser. You can run individual Javascript lines with browser development tools, but they're not as nice as having a Javascript "scratchpad" to try stuff out on.

How to Improve Performance of Shell Scripts

Shell scripts in Linux/Unix have the potential to do a lot of work. A lot of times they will start out as just a couple of lines written as a convenience to avoid typing in a few commands repeatedly. Then a couple more commands are added, then a couple more, and eventually you have a huge script that sets up your entire network, checks your email, makes you pancakes, and walks your dog.

One doesn't usually think too hard about the performance of shell scripts. But if you scripts do a lot of work, chances are you can make them run several time faster!

Thursday, November 10, 2011

How to Add Fonts to the Console in MS Windows

In the settings for the console in Windows, you have the option of changing the font. But the selection is fairly limited. There are usually only 2 fonts! But if there are dozens of fonts installed on the system, why are there only 2 for the console? Well, if this bothers you, there is a way to add to the list of available fonts for the command prompt on Windows.

Wednesday, November 9, 2011

How to set up a .rc file for the cmd shell on windows

In the Unix world, all command shells allow you to set up your command line environment by adding commands to 'rc' files, .bashrc, .profile, .tcshrc, .cshrc, etc... The cmd.exe shell on Windows does not have a '.cmdrc' file, so you are left with a default setup every time you start a new shell. Luckily, there is a way to source a batch file when cmd.exe starts.