Thursday, May 24, 2012

Electronics Repair - The Fuse

Let's face it, most people aren't skilled at electronics repair.  But that doesn't stop people from trying.  After all, if your TV stops working, it's out of warranty, and paying a repairman would cost almost as much as buying a new TV, why not try and repair it yourself?  What do you have to lose?

Back before I learned how to diagnose and repair broken electronics, I would always hope the problem was as simple as a burned out fuse.  Suppose you take apart that TV or other electronic item and you do indeed find a burned out fuse.  Simple fix right, you just replace the fuse?  Wrong!  Nine times out of ten, if you replace the fuse and turn it on it will burn out the new fuse.

The job of a fuse is simple, to protect against too much current.  Let me be clear, the fuse does nothing to protect against over voltage (such as a power spike).  The thing to understand about current, you cannot force current through a device, instead the device itself restricts how much current flows through it.  So if a fuse burns out this means one of several possibilities.

  1. The fuse was defective or weaken from age causing it to fail below its rated limit.  In this case replacing the fuse with a new fuse will repair the item.
  2. The electronic device was poorly designed, as a result it pulled slightly more current than the fuse was rated for.  In this case, replacing the fuse with a slightly higher rated fuse will repair the item.
  3. The electronic device has other faulty components which created an electrical short.  This short is what caused it to pull more current and burn out the fuse in the first place.  In this case if you replace the fuse, when you turn it on again it will just burn out the new fuse.
Again I want to be clear, #1 and #2 are rare, usually the problem is #3.  So if you find a broken fuse, you need to check the rest of the system for shorted or damaged components.  Failure to do so will just waste your time and money.

They put fuses into electronics because electronics fail.  If it fails with a short and there is no fuse, the device will pull more and more current, getting hotter and hotter.  Eventually the device could burn up or even explode.  So when it comes down to it, the whole reason for fuses is to prevent fires and explosions when electronics fail.

Programming Style

The mark of a good computer programmer is one who A) has a coding style and B) is consistent in its use.  But programming styles are almost as unique as the developer using it.  This becomes a pain when you're working on a project with other developers, or when you're copying code from the Internet.  Anyway, the main purpose of this post is to talk about two main coding styles.

Style 1 - Old-School
I don't know the name (assuming there is one) for this first style, so I'm going to call it "old-school" (more on that later).  In this style variables and function names are all lowercase, and the underscore (_) is used in place of spaces.  A typical block of code might look like this.

int string_length(char *input_string)
{
    int string_length = 0;

    if(input_string != NULL && *input_string != '\0')
        string_length = calc_length(input_string);

    return string_length;
}


Style 2 - Hungarian Notation with CamelCase
The second common style is a combination of Hungarian notation with CamelCase.  This means variables are prefixed with the type of variable.  Also variables and functions have the first letter of each word capitalized and don't use spaces.  In this second style the above function would look like this:

int StringLength(char *szInput)
{
    int nStringLength = 0;

    if(szInput != NULL && *szInput != '\0')
        nStringLength = CalcLength(szInput);

    return nStringLength;
}



Me personally, I greatly prefer the second coding-style.  It's easier to read (although that's largely due to the fact that I've been coding in this style for a decade).  It also is easier to type.  This style tends to be less wordy, plus it has fewer underscores which isn't the most convenient key stroke combination to type over and over.  Finally, I think it makes for better coding and debugging.  It helps to look at a variable and at a glance know what type it is.  If I see a variable "customer_number" I don't know, is it a plain number or is it a string representation of a number - which makes a huge difference.  But if I see "strCustNum" or "nCustNum" I know which type it is.

Lastly I wanted to explain why I referred to style #1 as "old-school."  As far as I can tell, this coding style originated in the 1960s or 1970s.  It's been around a while, and I would argue has been superseded by better styles.  Another thing I've noticed, style #1 is primarily used by Unix developers whereas style #2 is primarily used by Windows developers.

Friday, May 18, 2012

Windows 8 - not ready for primetime

There has been a lot of talk in the tech world lately about the upcoming Windows 8. For a while now Microsoft has made pre-release builds available for people to download and install. I decided to give it a try (on a test machine) and see what it's all about. I downloaded Windows 8 and installed it onto a virtual machine. Within 5 seconds I got this.
When I saw this I had a lot of different things go through my head:

  1. Is this a new BSOD (Bliue Screen of Death)?  If so, at least they kept it blue.
  2. Did Windows 8 seriously crash before I could even fully load the installer?
  3. I thought the Windows 8 preview was designed for and tested on virtual machines.  Heck, I'm using Microsoft's own Virtual PC 2007.
  4. Are you serious Microsoft - you used an emoticon in the error dialog?  I've come to expect a certain level of professionalism from Microsoft and emoticons in error dialogs is not part of it.
  5. Continuing the unprofessional theme, there are two contractions in the screen above.  As a general rule you should avoid contractions in computers and other technical documents.
I may try again on another machine, but my initial impressions are Windows 8 is a long way from being ready.