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

Polymorphism, part deux
Thursday, March 31, 2005

From the trivial corner of the obvious, I bring to you Polymorphism, part deux. Part one is here.

Riddle me this...Look at the following UML diagram - Do you know what will display when new Child().process() executes?

There is an "interactive quiz" for this entry, however, blogger doesn't allow JavaScript in their posts - Hm? I thought they were my posts and I could post whatever I wanted. I guess not - I may end up dropping their service for something more flexible.

Anyway, go to the interactive part of this entry »

11:53 PM | 0 comment(s) |

Running XMLHttpRequest with Java
Thursday, March 24, 2005

I had to get the XMLHttpRequest with Java demo running - It was running at one point, but my DSL provider keeps changing my dynamic IP address (Hence the name, dynamic IP address) - The demo now has a home of its own.

Running Pointless XMLHttpRequest with Java application.

When I decided to write my little app, I looked around for examples with actual code and didn't find any Java specific sites. So, for the benefit of curious eyes and code tinkerers, here is the code again - Hopefully you'll find the trivial example useful:
  1. The JavaScript
    This is where most of the work is done, via the XMLHttpRequest. This is JavaScript specific functionality and as per the time of this writing IE and FireFox were the only browsers supporting it - Opera doesn't, yet.

    This is the Servlet receiving the request - Nothing special about this class - It's your typical Java Servlet implementing doGet().

    This is a helper class - I abstracted this functionality out of the Servlet so I can reuse it. I.e. A Swing Application - BTW, you'll need to get your own key from google, if you want to run it on your own machine.

    This is your typical VO bean - I use it so that I don't couple the google API code with the Servlet.

7:27 PM | 19 comment(s) |

XMLHttpRequest with Java
Saturday, March 19, 2005

Everyone and their dogs are talking or writing about XMLHttpRequest.

I'm jumping in, together with my dog, to write about it and to say how cool it is. I've also developed a little application that uses XMLHttpRequest with Java.

But, that is not all. Since google is the new "new thing," I decided to use their 3 (or so) year old google API to embed searching capabilities to my little demo.

The Application
The application allows you to search google on the fly, via XMLHttpRequest.

Imagine, if you will, a blog entry form: this form is smart enough to perform an asynchornous google search of the title of your entry, as you finish typing in the value.

It looks like this:

The Source Code
As you start reading more about Asynchronous JavaScript and XML (AJAX), you'll notice that most of the work is done by the JavaScript code, which calls (in this particular case) the Java Servlet.

All the code:
  1. The JavaScript
    This is where most of the work is done, via the XMLHttpRequest. This is JavaScript specific functionality and as per the time of this writing IE and FireFox were the only browsers supporting it - Opera doesn't, yet.

    This is the Servlet receiving the request - Nothing special about this class - It's your typical Java Servlet implementing doGet().

    This is a helper class - I abstracted this functionality out of the Servlet so I can reuse it. I.e. A Swing Application - BTW, you'll need to get your own key from google, if you want to run it on your own machine.

    This is your typical VO bean - I use it so that I don't couple the google API code with the Servlet.
I had to take down the live version, but, I will try to put it up again.

The Application that I really want to write
I want to write an application that understands the "context" of my sentences as I'm typing my entry.

Why would anyone want to do that?
Think of it as a "smart" blog. I.e. As I type a blog entry, a "context" engine would be parsing my sentences and performing searches in the background.

When I'm done with my entry and click the "save" button, my entry and the search results are saved. My blog entry now has the top search results of whatever people are writing around the web about the theme(s) of my blog entry.

It sounds like a trivial problem, however, writing a "context" analyzer is not an easy task - If I had a context analyzer, I'd probably be licensing it right now :)

A pseudo product I'm working on (When time permits)
Another neat use I can think for this type of technology - no, not maps :) - is a type of web database updater.

For example, imagine using a web timesheet system (my product would be an extension to any system): whenever you are entering your daily (or weekly, or monthly) entries, you'd like everything related to a particular project to be updated in the background. Mmmhhh...GDS SDK.

4:29 PM | 5 comment(s) |

XP PowerToys
Thursday, March 17, 2005

I never take sides on the never ending debate of which OS is better, or which OS is more evil than evil itself. I use whatever is comfortable to me, or whatever I have at hand. To me it's all the same: U*IX, Linux, Windows XP, Mac OS X, etc, etc.

Lately, because I'm hooked on my ThinkPad T40p, I've been using Windows XP. I don't particularly like the XP bubbly look and feel, so I turn off all the useless fading effects and I ended up with something that looks like Windows 2000, which to me, is the best Windows version to date.

If you are a developer, you'll particularly like some of the extra "PowerToys" XP has to offer - They are probably not useful to the light user, but, if you are a developer and your keyboard is tethered to your hands, you may like some of them.

Picture within a picture
I remember the first time I saw a "picture within a picture" in TV screens. It was the coolest thing ever - I'm easily amused, so I found the enhanced "Taskswitch" to be quite the fun past time.

The "Taskwitch" program gets executed when you press the keyboard combination "Alt-Tab," which brings up this little set of icons that you can traverse to pick the window you want to bring up.

The old version had only small icons and you had to guess which window you wanted active. Well, with the enhanced version you get a picture of the content of the actual windows - A picture within a picture - See the little window with the blue background above?

Why is this useful? Because, if you are working with many windows at the "same" time, that have pictures or content, you can actually "view" the content of the windows while "Alt-Tab[ing]" and never be wrong about which window you wanted to activate. It's a neat trick. If you have a large pipe, you can view a more detailed version of the screen grab.

As per the rest of the "PowerToys," I have installed them all. Another favorite tool of mine: the one that allows you to right-click on an image so you can resize it to your liking, without opening any graphic manipulation program.

Find them all at Microsoft PowerToys for Windows XP.

It's not like M$ needs more free PR, but the tools are actually quite useful (for a change). Enjoy!

9:40 PM | 0 comment(s) |

Physical humor
Tuesday, March 15, 2005

Scientists, Physicists and Mathematicians can be funny.

The following joke spanned continents, the ages, professions and it fooled quite a few journalists and writers.

The story:
    The Globe and Mail, April 7, 1995, page A28 - The metric system.

    This is the 200th anniversary of the birth of the metric system, in France.

    * The system has seven fundamental, or base, measures. Many metric units are named for famous scientists (Newton, Coulomb and Kelvin) and one is named for a wine merchant -- Claude Emile Jean-Baptiste Litre.

    * Use of the system has spread internationally. In 1897, for instance, Britain passed a statute legalizing metric measures for trade and abolishing the penalty for using or having in one's possession a weight or measure of that system.

    Sources: Collier's Encyclopedia , Encyclopedia Britannica (1911).

The joke: Litre never existed :)

He was made up by Ken Woolner (the young man in the blue shirt), a Physics professor from Waterloo. As other science scholars read the story, they kept adding details of Litre's fictitious life. They even invented him a daughter, appropiately named: Millicent - Now, that's funny.

Woolner eventually fessed up, at the time of his retirement, to making him up "during a crippling blizzard in a hotel room in Ottawa, in December 1977." If it were not for his confession, we would still be celebrating Litre's legacy.

9:36 PM | 0 comment(s) |

Happy Pi day
Monday, March 14, 2005

Yes sir, it's March 14, 2005 or 3.14.

Looking for a fun way to celebrate π day? Follow the steps:
  1. Buy a real pie - I suggest an apple pie
  2. Round a group of people around the pie in a perfect circle
  3. At exactly 3:14:15 PM, have one person at a time, travel r (the radius) of the circle to grab a piece of pie
  4. Repeat until a full 360° has been completed
Instant π fun!

BTW, π = 3 in some states - Ok, almost: Indiana bill sets the value of pi to 3 - Your tax money hard at work.

BTW2, if you like math, you should watch "π The Movie." There is some math related content, but don't expect too much of it - After all, it's just a movie.

Plot: some math stuff; the secrect of the universe is revealed by an edible (finger licking) oozing home made super computer; and some dude with blinding headaches plays a lot of Go with some older dude; the whole movie is in black and white - Gives it more of a thriller kind of look.
Rating: π / 4 stars.

3:14 PM | 1 comment(s) |

Stupid JavaScript tricks...
Saturday, March 12, 2005

HTTP is a stateless protocol so we must invent ways to keep comunication between servers and clients in order to create highly interactive applications.

The new "new thing" is Ajax. This stuff has been around for a while, however, google made the news as the first one to successfuly deploy a real, usable application: (Ok, the maps is the second one, but, it is the most visible one).

New "new things" are part of the process of invention, but sometimes the little (and old) things used differently allow for neat little tricks. Sometimes is not only about the technology - It's also about the user and the presentation of information.

I.e. if you keep refreshing this site, the content on the right gets shuffled.

You can think of the randomization as just amuzement for the bored. A visitor will likely visit the homepage once in every visit, and some users only visit once in their lifetime. I'm almost cetain that most people won't notice the small change in every refresh, however, if you're like me, I tend to think that subtle differences in presentation make a big difference: nothing bleading edge here, no Flash, no Ajax - Just a stupid JavaScript trick.

12:23 AM | 0 comment(s) |

.com era, part two and why you should care
Sunday, March 06, 2005

In the late 90s, some of us developers rode the .com wave until the end. I am a proud .commer. There was a time when brick and mortar companies preferred to actually hire .commers. You may recall job descriptions reading ".com experience an asset."

The reasons to hire .commers varied; however, it was clear that .commers were, among other things:
  1. Highly motivated
  2. Worked well under pressure
  3. Well accustomed to work under unrealistic deadlines
  4. Needed little supervision
  5. Worked well among groups
  6. And the most important one, I think, big dreamers: if you can imagine it, we, .commers, can and will build it

    Note, that I left out the most obvious one: unemployed :)
Anyway, it was the "best of times and the worst of times."

A great amount of money was spent funding half baked ideas, but a few of those ideas were made into very profitable businesses. Some .coms, you recall, did actually go IPO, which was the intent of creating and working for a .com company. The other major reason for starting your own company: create a cool app and wait to be bought by Microsoft or Yahoo - And most recently, google.

Why am I reminiscing about the good times?

I have been saying to anyone that asks me that those days of debauchery will come back.

How do I know? I didn't know for sure: it was more of a gut feel--call it instinct. But there is no magic to my gut feels. If you think about it for a bit, everything behaves in cycles. Investment money being poured into the economy also behaves in cycles: we had a peak in the late 90s, we went through the lows, and we are going to start to go up again.

Cringely is saying it better than I can and adds a few facts to his claim:
    In 1999-2000 -- at the very peak of the dot-com boom -- venture capital firms were not only taking companies public at a furious pace, they were just as furiously raising new venture funds -- funds that will shortly be coming to the end of their lives. Throughout the fixed lifespan of these funds venture capitalists are typically paid 1-2 percent of the total fund per year as a management fee. If a VC raises $100 million for a fund with a six-year life, they'll take $2 million every year as a management fee, whether the money is actually invested or not. Any money that remains uninvested at the end of the fund must be returned to the investors ALONG WITH THE ASSOCIATED MANAGEMENT FEE.

    Right now, there is in the U.S. venture capital community about $25 billion that remains uninvested from funds that will end their lifespans in the next 12-18 months. If the VCs return those funds to investors they'll also have to return $3 billion in already-spent management fees. Alternately, they can invest the money -- even if they invest it in bad deals -- and NOT have to cough-up that $3 billion. So the VCs have to find in the next few months places to throw that $25 billion. They waited this long in hopes that the economy would improve and that technical trends would become clear so they could do their typical lemming-like jump off the same investment cliff as all the other VCs. Well, we're at the edge of the cliff, so get ready for the most furious venture investing cycle in history.

Why does this guy sound so sure? Well, he's been writing and making predictions for around 20 years or so, i.e., he has experience and a well established ethos--if experience means anything, anyway. There is no comparison to my (almost) 10 years of Software Development experience + my gut feel. But I wouldn't dismiss his ranting or my gut.

If he is right, hold on to your hats. If it is anything like it was in the late 90s, it will be a hell of a ride. If he's wrong, well, nothing lost: just wait for the next upward movement.

Why is this important to us, developers? I'm sure you don't base your career moves on what crazy people say/write on the Internet; however, it never hurts to keep your options open and your mind inventing "half baked" ideas. You never know whose interest you will grab with your next new "new thing."

I, for one, have my party hat on, as we'll be partying like it's 1999 all over again (like Prince predicted) and a long list of, truly, half baked ideas.

BTW, I don't like Prince (or whatever his name is now a days), but his song will remain timeless, similar to the first .com era.

9:18 PM | 0 comment(s) |

The Eclipse IDE story
Friday, March 04, 2005

Eclipse was unleashed to the open source community by IBM sometime around the year 2000 AD.

Recently, there has been a whole bandwagon of companies attaching their name to Eclipse, either as contributors or as supporters.

I, for one (and my dog), support and use Eclipse. However, my name is not big enough as most corporations to call for PR announcements, so keep it hush :)

However, I've been wondering why Sun doesn't stop "investing" resources and money developing NetBeans and just bite the bullet and join in the fun to try to make Eclipse the IDE of choice for the majority of developers.

If Sun did indeed officially support the Eclipse program, it may even end up obviating Visual Studio, which is the only direct competitor to Eclipse and why IBM actually made the IDE free in the first place.

For a more complete history of Eclipse, read what Lee Nackman, CTO of IBM's Rational Software unit, had so say about that: Eclipse On The Rise.

8:14 AM | 1 comment(s) |

Bizzare number series
Tuesday, March 01, 2005

    1 + 1 = 2
    2 + 2 = 3
    3 + 3 = 4
    4 + 4 = 5
    5 + 5 = 6
    6 + 6 = 7
    7 + 7 = 8
    8 + 8 = 9
    9 + 9 = 10
    10 + 10 = 11
This is probably the most bizarre number series I've ever encountered.

Number series come in all shapes and sizes. One of the most notable ones is the Fibonacci numbers:
    0, 1, 1, 2, 3, 5, 8, 13,...
To get the next number, you just add the last two numbers. I.e. 13 + 8 = 21. And you keep going on ad infinitum.

In more general terms, you can use a discrete function on the form of a recurrence relation:
    Fn = Fn - 2 + Fn - 1, n = 3, 4, 5, ..., and F0 = 0, F1 = F2 = 1

    - discrete, is a fancy term Mathematicians invented to say that you only use Integers as the input of a function
    - recurrence relation, means that the function calls itself to generate the next term
From a normal person's perspective, number series appear to be pass time activities for bored Mathematicians. Perhaps we wouldn't be so wrong thinking that, most sequences were probably found by playing around with Integers.

However, numbers are related to everything and the Fibonacci sequence is observed in a great number of very important natural phenomena. For a quick introduction, if you don't feel like reading a real book, visit Fibonacci Numbers and Nature.

Now, back to my bizarre number series: at first sight it looks like non-sense. After all, the only true statement is 1 + 1 = 2.

So, where did the rest of the terms come from?

I've been thinking about it for a couple of days now and I have a theory. But first, the story behind the numbers.

The Story
My four year old son, Gabriel, and I were reading "Desmond's Birthday Party." In the story, Desmond (a little dog) goes to town to buy materials to bake himself a birthday cake. His day is broken down into one hour periods. At 12 noon, the story goes, the clock tower begins to toll its bell for 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12 DONGS. During this part of the story, Gabriel enumerates the DONGS and off we go to the 1 O'clock page "which is lunch time," we both repeat.

Two days ago, before moving on, I asked Gabriel what "1 + 1" equaled to.

He replied "1 + 1 equals 2."

Great, I thought, he's learning how to add - This is a big step for him - So far he is only able to count from 1 up to around 31 without making any sequential mistakes.

After he correctly guessed (or added) "1 + 1," I asked him what 2 + 2 equaled to. He stopped for a few seconds and said "3." And then, without me asking, he kept on saying out loud: "3 + 3 = 4; 4 + 4 = 5; 5 + 5 = 6; 6 + 6 = 7; 7 + 7 = 8; 8 + 8 = 9; 9 + 9 = 10; 10 + 10 = 11."

I promptly asked him why he thought that "2 + 2 = 3."

He wasn't so interested in analyzing his results. He just wanted me to continue reading, to which request, I obliged and continue on. The story ends on a happy note: everyone eats the "delicious cake" Desmond baked at 3 PM (I've always wondered where his mom is in all this). And at 5 PM, his friends give him a wrist watch for his birthday present and, apparently, they all go home.

Gabriel loves the story. We read it every night before going to bed - Well, I do most of the reading - His job is more of a supervisory nature. I.e. Telling me that I'm in the wrong page when I'm skipping pages to make the reading session go a bit faster :)

The Theory
My theory on the number sequence is a follows: I think Gabriel figured out that "1 + 1" is actually 2, the only true mathematical statement in the series. Then he "reasoned" that because "1 + 1" gives 2, then "2 + 2" must give 3, and that "3 + 3" must give 4, et al.

His little mind followed, albeit wrongly, a discovered pattern from the result on one correct observation: adding the same number twice gives you the next number in the Integers following the number you just added, which is only true for the number "1."

In other words, the number "1" is the only number that added twice gives as a result the next number in the sequence of Integers after itself. I.e. the next number after 1, is 2. So, 1 + 1 = 2.

Try it: every other number, except 1, when added twice doesn't give you the next number in the sequence of Integers (See below, for the proof). BTW, I don't think Gabriel knows this particular fact.

So, in Gabriel's little mind, the pattern he is following makes sense (He still says that 2 + 2 = 3). And so, I propose the "Gabriel Number Sequence," officially discovered by my four year old son. Which leads to the "Gabriel Theorem."

The Grabriel Theorem and The Proof
    Theorem: Let n be an Integer > 0. Then, the only possible solution for the equation n + n = n + 1, is n = 1.

    I.e. the only number n, where its immediate successor n + 1 in a sequence of Integers, that when added twice gives as a result the next number in the sequence of Integers (or n + 1), is n = 1.
Proof 1
    We can prove this fact with the aid of 7th grade algebra:

    Let n be an Integer > 0. I.e. 1, 2, 3, ...
    In order for n + n to have be the next Integer in the sequence, the result must be n + 1. I.e.
    n + n = n + 1
    2n = n + 1
    2n - n = 1
    n = 1

    Substituting back, we get:
    1 + 1 = 1 + 1
    1 + 1 = 2

    Therefore, n cannot be anything, but 1 and so, we've proved the "Grabriel Theorem."
Proof 2
    A more sophisticated proof (I'm trying to be funny here), by reductio ad absurdum:

    Assume that there is an Integer n > 0, that satisfies our requirement. Namely, that n + n = n + 1.
    Assume that such Integer exist, and so we can try the next Integer in the sequence. Namely (n + 1). Thus:
    (n + 1) + (n + 1) should give (n + 1) + 1, or the next Integer after (n + 1).

    (n + 1) + (n + 1) = (n + 1) + 1
    2(n + 1) = (n + 1) + 1
    2(n + 1) - (n + 1) = 1
    n + 1 = 1
    n = 1 - 1
    n = 0

    Which, is contradictory to our definition: n > 0.
Extra geeky stuff: what would Piaget say
Thinking about Gabriel's discovery, I started recalling Jean Piaget's theory of early childhood development. To put it in context, what follows is a minimalist and bastardized version of Piaget's research:
    In the sensorimotor stage (0-2 years), intelligence takes the form of motor actions.

    Intelligence in the preoperation period (3-7 years) is intuitive in nature.

    The cognitive structure during the concrete operational stage (8-11 years) is logical but depends upon concrete referents.

    In the final stage of formal operations (12-15 years), thinking involves abstractions.
The stage of interest for this entry is the period between 3-7 years of age. Piaget proposes that children's intelligence is developing via intuition. Interesting stuff.

In this particular case I'll let you make your own conclusion, however, Gabriel's discovery kind of makes sense when you really think about it: he's making an assumption based on one single correct observation. Instinctively, he's sure that "3 + 3 = 4," otherwise, he wouldn't continue on with his number sequence, all the way up to 11.

To put things in perspective and to give a more "real" example of intuition and reasoning: imagine telling someone, who doesn't know what a prime number is, that 3, 5, and 7 are prime numbers and then asking what is the next number in the sequence.

A most sensible answer would be 9.

If I didn't know what a prime number is, I'd would rationalize that 3, 5, and 7 are odd numbers, and thus 9 is the next prime. Not only that, I would confidently say that all odd numbers are prime - Of course, we all know that this is horribly wrong, however, the observation is made based on a widely known fact: 3, 5, and 7 are odd numbers.

I can't remember when was the first time I learnt about prime numbers, but, I'm almost certain I made such horrible mistake.

For those of us, who don't know or remember: a prime number is an Integer that can only be divided by 1 and itself, and must be greater than 1. For example, 4 is not prime: 4 = 2 * 2.

BTW, if this silly fact has been proved before, I have never seen it and hence the claim of the "Grabriel Theorem." If this trivial piece of Mathematics has already being published, shame on the publisher, and obviously my apoligies to the other author. The result of this "theorem" was the result of a few minutes of leasure time.

BTW2, I haven't broken the news to Grabiel that 2 + 2 is not 3. I haven't had the heart. I'm also hoping he'll eventually figure out the truth all by himself.

12:45 AM | 1 comment(s) |

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

© Jose Sandoval 2004-2009