Thursday, October 22, 2009

Intertech - Course Planning

I'm putting the finishing touches on the follow-up to my "Access Modifiers" entry, but first wanted to make a quick request for some feedback.  Here at Intertech - http://www.intertech.com/  - we're investigating new topics and technologies that we can add to our training offerings.  Your opinions on this are important, so if you could take a few minutes to fill out a survey by clicking this link: 2010 Intertech Course Planning Survey... I'd really appreciate it!

... and as an extra incentive, you'll receive a coupon for $250 off any Intertech training course in 2010 - just for completing the survey!


Subscribe

Friday, October 9, 2009

Access Modifiers in Java


I've always felt that the standard explanation for Access Modifiers in Java:
  • Public = Accessible to All
  • Protected = Accessible to the Class, any Class in the same Package, and any Subclass
  • Default = Accessible to the Class, and any Class in the same Package
  • Private = Accessible only to the Class itself. 
...wasn't entirely accurate (and admittedly, since most designs stick with basic encapsulation: private fields and public methods, more specific details are often academic).

So to illustrate the complexity, I've created three simple classes.  The first two, "Parent" and "Child" are in the same package.


package com.intertech.examples.java.accessmodifiers;

public class Parent
{
   public void printPublicMessage()
   {
      System.out.println( "printPublicMessage()" );
   }

   protected void printProtectedMessage()
   {
      System.out.println( "printProtectedMessage()" );
   }

   void printPackageMessage()
   {
      System.out.println( "printPackageMessage()" );
   }

   private void printPrivateMessage()
   {
      System.out.println( "printPrivateMessage()" );
   }
}


and ...


package com.intertech.examples.java.accessmodifiers;

public class Child extends Parent
{
   // Does nothing but extend Parent
}


Which methods from "Parent" do you think would be visible to the three objects below (note that this class extends Parent as well, but is in another package). 

package com.intertech.examples.java.accessmodifiers.another;

import com.intertech.examples.java.accessmodifiers.Child;
import com.intertech.examples.java.accessmodifiers.Parent;

public class AnotherChild extends Parent
{
   public static void main( String[] args )
   {
      Parent parent = new Parent();
      /* which "Print" methods from the Parent class would be visible for this Parent object? */

      Child child = new Child();
      /* which "Print" methods from the Parent class would be visible for this Child object? */

      AnotherChild anotherChild = new AnotherChild();
      /* which "Print" methods from the Parent class would be visible for this AnotherChild object? */
   }
}

Try to do this without putting it into an IDE or running the actual code. I'll post the answers next week with some further explanation.  You can find more information on "Complete Java" or other courses taught at Intertech - by visiting our website: http://www.intertech.com/

Thursday, October 1, 2009

Microsoft Security Essentials: Freezing / How to Remove

Microsoft recently announced a free anti-virus application called "Microsoft Security Essentials" - http://www.microsoft.com/security_essentials/

While most of my friends have installed this without issue, I had the complete opposite experience: immediately after the updating of the signature files, my computer froze.

Restart -> Freeze -> Restart -> Freeze -> Restart -> Freeze... grr...

Each time I would do a hard shutdown (by holding in the power button), and restart, I would attempt to remove the software. Unfortunately, my computer would freeze before this was possible. Although the installation does tell you to remove other anti-virus / anti-spyware software, which I did, I believe that my issue was the result of a conflict with a firewall. [Edit - 10/1/09, 3:10 PM - According to this comment and this other comment, it looks like my firewall was the likely culprit]

No big deal, I've had software conflicts before: boot into safe mode and remove the software.

That's when I saw this:


"Can't run the Microsoft Security Essentials setup on a computer running in safe mode." Great. I can't remove the software in normal mode and I can't remove it in safe mode. Now what?!

After a few trial and errors here are the steps I took to be able to uninstall the app...

To be clear, I'm not encouraging people to uninstall or avoid this software; if my computer hadn't exhibited this effect, I would be using it right now! These are just instructions you can use if you are having the same issues I was (i.e after installing MSE your computer freezes. You decide you want to uninstall it, but are unable to do so). For those of you that fit this description, you can follow these steps - at your own risk, of course :)


Step #1:
Reboot into Safe Mode. In most versions of windows, this is done by tapping the F8 key during boot-up.
If you are unfamiliar with how to do this for your specific version of Windows, just check google; there are tons of "how to boot into safe mode" websites out there...)

Step #2:
Start up MSCONFIG: go to the Start menu, type "MSCONFIG" in the search box.


Step #3:
Select the "Selective startup" radio button in the "General" tab.


Step #4:
Uncheck "Microsoft Antimalware Service" from the "Microsoft Corporation" in the "Services" tab.
If you are having trouble finding this, you can click the "Service" header and it will sort the list alphabetically.


Step #5:
Uncheck "Microsoft Security Essentials" from "Microsoft Corporation" in the "Startup" tab. Click "OK"


Step #6:
MSCONFIG should ask you if you want to restart (or it may do it automatically after clicking "OK"). Allow it to restart and after windows has finished loading, uninstall Microsoft Security Essentials as you normally would (typically through the Control Panel).


Step #7:
Load MSCONFIG as you did in Step #2, and return the "Startup selection" to "Normal startup." Click OK, and restart your computer.
Good Luck!!!

Subscribe