Jose Sandoval Google
 Resume     Book     Software     Drawings     Home     Subscribe to RSS feed Search Web Search

Java inheritance
Thursday, October 21, 2004

Inheritance, together with encapsulation, and polymorphism are the
pillars of Object Oriented Theory.

Java is an Object Oriented programming language. Some purists debate
it's OOness, as it doesn't treat int, char, boolean, and byte as
objects. However, Java is an OO language whether we like it or not.

Java has the notion of protected members, which are only available to
to extending classes and class which reside in the same package as the
"protecting" class.

Now, if I wanted to get access to those protected members outside of
the package and would prefer not to use multiple levels of
inheritance, how do I get access to those members?

For example:
1. Let say, you have a class with protected fields and methods in ClassA.

2. Let say, you have your working class (ClassB), which is already
extending one super class (Java has single inheritance, after all).
Now, you need some functionality from ClassA. How do you get that
functionality? Without layering your inheritance chain and growing
your object without reason?

One solution:
Extend the classA and have provide accessor methods to get to the
protected members of ClassA, then use composition, rather than

Now you have all that code available everywhere and anywhere.

A quick example:

class SuperClass {
public superValue = 42;

class WithProtection {
private int toReturn = 666;
protected static final String PROTECTED_KEY = "PROTECTED_KEY";
protected int protectedInt() {
return 666;

class WorkingClass extend SuperClass {
public static void main(String[] args) {
System.out.println("superValue = " + superValue);

// I want WithProtection's funcationality. How do I do that?
// Without creating an unnecessary chain of inheritance.
// Se below for WrapperClass code
WrapperClass wrapperClass = new WrapperClass();
System.out.println("WithProtection.PROTECTED_KEY = "
+ wrapperClass.getKey());
System.out.println("WithProtection.protectedInt() = "
+ wrapperClass.getProtectedIntMethod();

class WrapperClass extend WithProtection {
public String getKey() {
// This field is available

public int getProtectedIntMethod() {
// This method is available also
return protectedInt();

The output:
  superValue = 42
  WithProtection.protectedInt() = 666

Cool, ah?

7:30 PM | 0 comment(s) |

Fine Arts - Still life
Wednesday, October 20, 2004

I'm taking a Fine Arts class at the Arts Faculty of the University of Waterloo. This particular class is composed of 100% in studio work, involving 3 different art genres: print making, drawing, and painting.

I'm currently completing the drawing component of the class, and after 6 hours of studio work, I can say that drawing is bit more involved than what I had expected. I had only drawn in small 11"x8" paper - Nothing compared to the real thing. As my instructor said: "Drawing is like fencing." There is a proper stance, a proper easel angle, etc, etc.

These are a couple of my first, ever, in-studio still lives, using proper drawing techniques:

Drawing properly is all about proportion, depth, and value (shading). Ok, it's not just that, however, I want to break it down into something logical that can be perfected with practice, plus a touch of art.

You can't see the unproportionality of my tables - After all you can't see the real scene - but, trust me, they are not proportional.

More artsy stuff...

11:15 PM | 0 comment(s) |

First day of school
Thursday, October 14, 2004

A day in the life of a four year old boy in 6 points. His real name is Gabriel.

1. When he was enrolled for school for the very first time, someone at the office made a mistake and enrolled him in Senior Kindergarten.

He's four, so he should be in Jr. KD.

2. Because he is a bit taller than some of the other kids, his teacher didn't question his presence in her classroom.

3. In the introductory parent-teacher day, the teacher asked him if he's been in school before.

Gabriel cheerfully says "Yes." The teacher believes him.

Later that day, Gabriel's mom made clear to the teacher that he's never been to school before, hence, he is now evaluated as Jr. and not Sr. This is important, since he seemed a bit immature for Sr. KD. and his scholastic evaluations would have indicated his age and progress deficiencies.

4. In the first day of classes, as the bell rings announcing that play time is over, the children walked into the classroom and were met by a table with name tags spread all across it.

Each child was to pick a tag corresponding to his or her name on it. All kids did so, except for Gabriel. Two tags are left and he picked up one at random. Gabriel doesn't know how to read yet, so he grabbed the one that read "Tyler." His name for the afternoon will be "Tyler."

The teacher asked Gabriel, to confirm, "Is your name Tyler?" Gabriel answered, "Yes, Tyler". The teacher looked back at the table and saw the last tag with the name "Gabriel" still left on the table. She now has a Tyler, but there is no Gabriel. The question is: where is Gabriel?

5. In Canada, attending school is mandatory until you are 16 years of age. Gabriel's (Tyler's, rather) teacher called his house and left a voice message asking why Gabriel was not in school.

Tyler's mom came home and checked the answering machine. Panic stroke her while hearing the message, as she personally had dropped him off earlier that afternoon. She continued to review the voice mails and to her relief there was a second message, which said to disregard the "absent notice."

6. What happened?

As the lazy afternoon wore off, the teacher kept calling Gabriel "Tyler." And why wouldn't she, his name tag said so.

In one of the occasions, the teacher called on our "Tyler." This time Gabriel looked at her and said: "My name is not Tyler. It's Gabriel."

The mystery of the missing Gabriel was solved and from that day on for a whole week, Gabriel arrived home with a sticker on his chest with 7 letters in it: "GABRIEL."

Maybe, it wasn't a typical first day of school, but it was certainly one to remember.

11:30 PM | 0 comment(s) |

0069 or 6900?
Tuesday, October 12, 2004

The number 69 is one of those ambiguous numbers. What I mean is that the number looks correct regardless of the orientation - It doesn't have a top nor a bottom.

However, if you put anything on either side of it, it does have a top or a bottom - And when there is something in front of the number, surprisingly enough, things happen or don't happen.

For example, over the weekend, the company I'm contracting for moved. One of the moving procedures had everyone stick labels on computer equipment, chairs, and plastic bins, which contained all our belongings. My new office number is 0069. I'm in the first floor of a new building, and all the office numbers have a '00' in front it. However, the label on my door read as follows:

Jose Sandoval

So, this little mishap (upside down label), resulted in some of my furniture and phone equipment to get lost. All my things were labeled 0069, but no one could find the office.

You'd think, though, that logic would prevail and someone could have figured out that there are only 3 floors in the new building, thus, rendering office "6900" non-existent - As customary in Canada, the prefix "6" would be used for the sixth floor only. But, that wasn't the case - I guess in the middle of the move and the hectic weekend, 6900 looked more correct than 0069.

Oh, well. I managed to find my chair and my phone - And I'm glad to inform that I'm up (I should say sitting up) and running - Also, as the result of the move, I have a real office for the first time in my professional career - Yes, the office has a door.

8:30 AM | 0 comment(s) |

Blocking ads for free
Friday, October 08, 2004

This entry may sound like all the empty promises of ad blocker software vendors, however, my way is free and is based on a solution that requires no software nor any install of any kind.

The internet and the web are one the few marvels that came out of the 20th century. In one occasion, my Distributed Systems professor and I (University of Waterloo) discussed briefly how the whole infrastructure miraculously works and how fragile the whole system is. Of course, this is an over simplification of the whole infrastructure behind the theory and hardware necessary to make networks work. There is amazing CS, Engineering and Mathematics behind it all.

If you are interested in a small part of the theory, you can google the OSI reference model and find around 369,000 links discussing OSI.

Anyway, I mentioned the theory behind the internet to introduce the solution I use to block ads of all kinds - I have to mention that it has been around for quite a while, however, I don't think people know the details. So, I'm offering the solution in just a couple of steps:

Step 1
Read this site: Blocking Unwanted Parasites with a Hosts File, but don't install anything from that site (If you want, you can, but I wouldn't as I said that the solution I'm presenting doesn't require any software installs).

Step 2
Create your own hosts file with the content from here: Mike's hosts file. Use your favorite text editor and remember to name the file "hosts" - No extension.

Step 3
Place the hosts file you created in Step 2 noting your Windows version - The location is important:

  • Windows 2000 - C:\WINNT\SYSTEM32\DRIVERS\ETC
  • Win 98/ME - C:\WINDOWS

Why would you want to do this?
The main reason you want to do this, is to surf the internet faster, as ads take a lot of bandwidth to download those annoying images - This is a big plus, if you still use a dial up connection. Also, it can save you a few headaches with virii and adware, as some of this programs are installed via pop ups and ads which contain JavaScript code or something similar.

I've been using it for a while, and I really don't think I'm missing much by not seeing all those ads - I'm almost certain, that you wouldn't miss much either.

How does it work?
By design, machines connected to any TCP/IP network can use domain names as opposed to IP addresses to connect via the network - The engineers of the system thought of it this way: it is easy to remember "," rather than ""

So, any TCP/IP enabled machine (If your computer has a network card, it is likely TCP/IP enabled), first goes to this "hosts" file in your computer and looks up the domain name you are looking for and translates the human readable name to a real IP address.

If you notice closely, all the entries in the hosts file (From Step 2 above), all point to "" - Which is a loop back address to point everything to the local machine - Again, something the creator of the technology thought it would of some use. It means that your machine alone is still a network - A network of one. I.e. A network with one node, is still considered a network, as far as your TCP/IP hardware is concerned. Therefore, everything that should come from all those ad servers, likely images, is routed back to and the requests never leave your machine, thus, saving you bandwidth and making your internet experience much faster.

On a side note, given the ".com" 90s, the originators of the system never thought how popular their idea would become. I.e. is considered to be one of the most valuable internet real state around - I know, real state that doesn't exist, except for a few lines stored in some database somewhere - Turn the power off, and, poof - It's all gone - I did say that the whole system is extremely fragile.

11:35 PM | 0 comment(s) |

Java versions
Friday, October 01, 2004

I've been doing Java development for some years now, and I still get confused by the versioning and naming convension Sun adopts.

The new Java version: JS2E 5.0.

You are thinking, hey, why did it jump from 1.4.0_X to 5.0?

Sun should be able to explain it better at their J2SE 5.0 Name and Version Change page.

If you are curious, I've worked with all the versions: 1.0, 1.1, 1.2 (After this version, it was known as Java 2), 1.3.X, 1.4.X_X (A lot of companies are not even here yet - At the time of this writing), 5.0 (I've played with the generics stuff - At the time of this writing).

BTW, Sun has used this naming convention in the past. For example, Solaris 1.8 is known as Solaris 8, same as Solaris 1.9 is knows as Solaris 9.

8:15 AM | 0 comment(s) |

This page is powered by Blogger. Isn't yours?

© Jose Sandoval 2004-2009