Search The Web

Today's Headlines

Monday, November 2, 2009

My Project And Javascript Frustrate Me - But Not For Long!

Today was a bit of a frustrating day, but with a good end. All is well that ends well, right?

So, what caused the frustration? Two major things. The first was more pain from my project. My manager wants week-by-week project plans for the project rather than a project plan that devotes 4 weeks to design, 12 weeks to coding, 4 weeks for testing, and so on. This is quite unprecedented in my project-planning and project-leading experience. I doubt any project that is supposed to take more than a couple of months is planned down to the weekly level anywhere.

So, my curiosity was a little piqued. Why was my manager asking me to indulge in this masochistic waste of time? It is not as if we have taken up projects in the past and failed to deliver on them because of the lack of detailed project plans. At first he only said that his boss, my director, wanted to see the project plans at that level so that the project could be tracked more closely.

However, my boss's boss is not exactly a masochist (or sadist) either. She is detail-oriented and rose through the ranks from being a programmer to where she is now, so she is comfortable with the technology and tools we use, but she has no need to monitor our progress on a weekly basis. She does not have the time to do it, and I am sure she would consider it quite painful if she had to monitor the progress of our project on a weekly basis (our department is probably working on 15 to 20 projects right now, and I am certain that none of them are tracked any more closely than on a monthly basis).

Ultimately, after some more probing, parts of the truth are coming out, and that is what is causing all my frustration. It turns out that it is the IT folks who we will be working with who are asking for a detailed project plan. As I posted before, IT claims to be overloaded with projects (aren't they always?), and want to delay as much as possible their support activities for this project. That includes providing us the data we need, without which we can't start doing any work on the project. Now, they want to dump some busy work on us so that we can keep ourselves busy while they take their time coming up with the resources that will enable us to start doing real work on the project. I have always known our IT department to quite incompetent, but the new director over there has started coming up with some pretty creative ways to try and hide the incompetence: I guess he hopes that if he keeps us busy enough, we won't notice their incompetence!

After I learned this much, I asked my manager whether we are going to be getting a week-by-week accounting of what IT will be working on so that we can know with some certainty when the data we need will be ready. As I expected, the answer is no! Obviously, given that they don't even have time to work on providing us the data we need, it is too much to expect them to actually provide us a plan for when they hope to get around to it!

The IT director is also interested in "reviewing" our mathematical models once our solution design is complete, before we start coding on the project. What we do in our department is quite an esoteric branch of mathematical modeling, having to do with linear programming, integer programming, heuristics, meta-heuristics and other stuff that most people outside my department would rather not get into the details of. Most are happy that the models we provide to them work, and produce good results that they probably couldn't get to by hand. If we started explaining the intricate details of our solution methodologies, their eyes would probably glaze over first, and it would probably progress to some pretty serious, as-yet-undiscovered medical condition soon thereafter!

So, what makes this director in IT not only want to hear the details, but also review them? Never mind that I don't consider him qualified to review the details even if he turns out to be masochistic enough to want to hear the details. I have been doing what I do for almost 15 years, and believe me, I know what I am doing most of the time! Our IT department, on the other hand, has never inspired much confidence in me, even in areas where they should be the experts. I have a feeling it is just one more tactic to get us to spend time on putting together presentations and attending meetings rather than working on our project.

One of the IT-bungling episodes I tell people, if and when they ask me why I think our IT department is incompetent, happened way back when Microsoft released SP2 for Windows XP. Our IT department told all of us to check our automatic updates setting to make sure that it was set to manual only. The reason was that they did not want anyone installing SP2 on their computers until IT was done "checking its compatibility with our hardware and installed software". Like a fool, I actually complied with their instructions and did not install SP2. In fact, when SP2 came up as one of the automatic updates, I asked the computer not to install the update and also asked it never to prompt me to install it again.

Fast forward a year and a half, and IT was still "evaluating" SP2. In the meantime, the dates for daylight savings time changed, and the automatic update that enables windows computers to move to the new daylight savings time schedule could not be installed on my computer because - you guessed it, it was compatible only with SP2. So, while some computers in my department adjusted to the new daylight savings time schedule on the appropriate dates, many of my colleagues were left with computers that sprang forward and fell back on the wrong dates. During the time when some computers were in daylight savings time and others weren't, our calendars were a complete mess. Depending on who put the meeting on whose calendar, appointments were off by an hour this way of that way, causing massive amounts of confusion for about 3 weeks. In fact, we took to inserting the meeting time in the actual text of the message rather than letting people rely on the calendar to tell them when the meeting was.

Fast forward some more time, and SP3 for Windows XP came out. IT once again sent out a stern warning to everyone not to install the "untested" service pack on their computers. Never mind that they still hadn't delivered a verdict even on SP2! Yes, I know, it is hard to believe, but they ARE that incompetent. But, I had already learned my lesson with SP2. Even before the service pack was downloaded to my computer as part of automatic updates, I went to the Microsoft website, manually downloaded SP3, and installed it the day it was released. My computer works perfectly fine with no conflicts either with "our hardware" or "our installed software".

Give me a break. Our IT department does not put these computers together from scratch. These are standard name-brand computers with pretty famous name-brands. I am sure the manufacturers of these computers have tested these updates and found nothing wrong with their computers or with the update. Our software is also pretty much standard-issue stuff like Microsoft Office and Internet Explorer. Why an update from Microsoft would break any of that is beyond me. I am not saying that Microsoft is perfect or that their software never breaks, but when it comes to comparison our IT department doesn't even hold a glow-stick to the engineers at Microsoft (leave alone candles and other shiny objects)!

By the way, we still don't have a verdict from our IT department regarding either SP2 or SP3! But by now, you must have guessed that, right?!!

So, I told my manager frankly that this IT director had no business reviewing our mathematical models even if he wanted to. But my manager wants to play nice and go along with IT, and dance to their tunes and what not. I have a feeling the politics of this project at his level are much more horrendous than at my level, so he is forced to do some things even he probably does not want to or like to. I am hoping that once we pry the data out of IT's control finally, we will be left to ourselves to complete our part of the project in relative peace. It IT can play games, I am sure we can too. We just need to play their game when we are waiting for them to give us something. When the tables are turned, I wonder how nice or nasty my manager and director are going to be with IT. I would love to be a fly on the wall when they meet with their counterparts in these endless meetings that seem to take place practically everyday nowadays.

Anyways, enough of that. My second frustration was with a bit of software code that I was trying to write. The problem is that it was in a language I am totally unfamiliar with. My requirements were quite simple: I needed some way to accomplish the following: load a random website among several I provide the program with. After displaying the loaded website for a random amount of time, load a different random website. Continue process until I close the browser down. So, random website, random display time for each website. That's it. I did not care how the website was loaded, I did not care about popups, separate tabs, frames, whatever worked, I could live with.

Seems simple enough. It turns out to be quite a chore. There are programs out there that will keep reloading a website at regular intervals for as long as you want. Doesn't satisfy either of my requirements, but it is out there as a ready-made, packaged solution. There is in fact a Firefox extension called ReloadEvery that does it reasonably well.

I started doing an internet search. I quickly uncovered several code snippets from various sites that did the tasks I wanted done, but separately. Some scripts would load one out of a set of given websites every time you refresh the page. Other scripts would load the same page at random intervals of time. Still others, you gave them the websites and the times for which they should be displayed, and they picked a random website (and its corresponding display time) and displayed it for the given time before rotating to another random website and so on.

I thought it would be relatively easy to cobble together a couple of these solutions into one that would accomplish both my tasks, but that was not easy either. Some solutions used frames, others used popup windows. Some relied on button clicks, others would only work for locally hosted sites, still others wanted to delve deep into the DOM to use some esoteric features that I couldn't get my head around. And the litany of incompatibilities went on and on.

Ultimately, I waded into the fray myself and cracked open a Javascript book to start learning the basics. It was the first Javascript book I have ever read. Learning the language wasn't too difficult (obviously, I was not concerned with the minute nuances of advanced Javascript), but getting the thing to work was worse than pulling teeth.

The whole concept of "silent failure" is probably the most frustrating concept a programmer can ever be confronted with. Please, give me a break. I understand that browsing should not be affected by errors in somebody's script, but at least give me an option to turn something on in my own scripts so that I can test and debug them! Without feedback from my programs, how am I supposed to figure out what they are doing and correct them? I think from that point of view, Javascript is the most brain-dead language I have been exposed to!

After spending a few hours trying all kinds of things, I was almost about to give up, but ultimately, things clicked. I was able to accomplish what I wanted late in the day. I have attached the program to this post for others who may want to use something like it or, God forbid, try to modify it to suit their own needs!

I ran some errands on the way home. Then, at home, I exercised before having dinner and writing up my day's activities for this blog post. I have managed to stick to my interval training workout (which I programmed into my treadmill a few weeks back) at least thus far. I do it once, sometimes twice a week, every week. Every Monday evening, I do interval training. On Wednesday evenings, I get enough of a workout at my Karate class. Then on Friday evening or Saturday morning, I do either interval training or walk up a 12% incline for about an hour while reading a book. Which I do depends on the mood I am in on that day!

By the way, I haven't noticed any change in myself since I started the new workout. Some people claim that exercise invigorates them or refreshes them or whatever. Exercise has always made me tired and continues to do so! I don't think there is anything wrong with me or with my exercise. Exercise is supposed to be hard work, and hard work is supposed to make you tired!

So, why do I consider the day to have ended fine? Well, one of the frustrations is going to be ongoing for at least the next few months. I have decided that rather than considering it a frustration and getting myself all worked up, I will consider it an entertainment and have a good laugh about it every chance I get. The other problem which I started the day with actually got solved to my satisfaction. I can't ask for more, and I am not going to!

Anyways, before I forget, below is the Javascript for loading a random webpage for a random amount of time in a browser. Good luck modifying it to your needs if you need something similar but not exactly the same! Some of the code came from Dynamic Drive, so their copyright comments are left in place in the code. But the entire code is not theirs. By the way, the code looks yucky with no indentation after I posted it here, but I will leave that mess for somebody else to fix!

//Random iframe content- © Dynamic Drive (
//For full source code, and Terms Of use, visit
//This credit MUST stay intact for use

var ie=document.all&&navigator.userAgent.indexOf("Opera")==-1;
var dom=document.getElementById&&navigator.userAgent.indexOf("Opera")==-1;

//Specify IFRAME display attributes
var iframeprops='width=100% height=100% marginwidth="0" marginheight="0" hspace="0" vspace="0" frameborder="0" scrolling="yes"';
var thisInterval;

//Specify random URLs to display inside iframe
var randomcontent=new Array();

if (ie||dom)
document.write('{iframe id="dynstuff" src="" '+iframeprops+'>{/iframe}');;
//replace the curly braces in the above line with triangular braces.
//Blogger does not allow me to post triangular braces without taking
//it upon itself to interpret them and make a mess of my post

function random_iframe(){
var now = new Date();
var secs = now.getSeconds();
var raw_random_number = Math.random(secs);
var random_number = Math.round(raw_random_number * 600000 + 600000);
//change the two 600000's in the line above to change the interval
//to your liking. In my case, these represent my desire to change
//the website that is displayed every 10 to 20 minutes. The times
//are in milliseconds.

REFRESH_INTERVAL = random_number;

if (ie||dom){
var iframeobj=document.getElementById? document.getElementById("dynstuff") : document.all.dynstuff;
thisInterval = window.setTimeout("random_iframe()", REFRESH_INTERVAL);

thisInterval = window.setTimeout("random_iframe()", REFRESH_INTERVAL);

All of this code has to be in a proper HTML document with head, body and script tags (in particular the entire code above has to be enclosed in script tags). I can't post that entire HTML code here because blogger will start interpreting the tags and create a mess out of the entire post. Good luck!


Anonymous said...

Hi, if you're using firefox you can use the error console (built into firefox, under the tools menu) to report on errors. For actual debugging (breakpoints, etc.) you can use the Firebug extension. Most web developers swear by it.

I suppose if your IT dept is stupid, you might not have access to firefox (though I think there is a standalone version that doesn't install called "portable firefox"). IE8 has its own debugging tools as well, just pull up the dev console by hitting "F12". I believe that has advanced error reporting and debugging as well.

John said...

Hi, here's an alternative take on the random website loading problem. It uses the object-oriented Javascript approach rather than the imperative way taken in your post.

I did this mainly to brush up on the object-oriented Javascript paradigm.

Blogannath said...

Thank you very much, Will. I will certainly take a look at Firebug. The standard browser where I work is IE, but I do have Firefox on my computer because our computers are not locked down. But good tip about the portable version of Firefox also.

Blogannath said...

Thanks a lot for your code, John. I appreciate you taking the time to put that together. It will probably take me some time to analyze the code and understand it since I am so new to Javascript, but I will certainly test it out and see how it does. Thanks again!

Visitors Country Map

Free counters!

Content From

In the News

Article of the Day

This Day in History

Today's Birthday

Quote of the Day

Word of the Day

Match Up
Match each word in the left column with its synonym on the right. When finished, click Answer to see the results. Good luck!



Spelling Bee
difficulty level:
score: -
please wait...
spell the word:

Search The Web