Here's
my
Floating
Div
To see my development blog, go here
To see what Dan has to say, go here

Tuesday, November 21, 2006

Programmers were meant to work < 30 hours a week

I've got to say, I am pretty displeased with the state of overwork all of us developers are in. Too many of us are ground to the bone working as much as 35 hours or more a WEEK! Its happening all over the world. Companies are lumping us programmers in with the regular work crowd expecting the same kind of hours, dedication, and results.

I will admit, there does exist a national dilema regarding the general overworked employee. Numerous studies are out regarding this and I must say I see a real problem. However, certain factors of a programmer's life make this level of work more extreme and unfair than it is for non-programmers. I have composed a list that illustrates my point.

1. Game time - Developers are severely limited in their playable game time. Sure games are a great stress reliever where a person can decapitate someone in fantasy land instead of doing it at the office, but they mean more to a programmer. A programmer needs 1-8 hours a day in an environment where he can get away from the idiocity and stupidity of the world (which doesn't involve a lot of reading). Also, unlike other people, programmers are creative. What better way to exercise that creative spirit than to enter a world of make-believe whether that involves stabbing a dragon or emancipating the head off of another soldier in battle?

2. Television/Movies - These are essential. 1-8 hours a day is required for this endevour. Television and movies basically perform the same function as item 1 except with a lot less effort involved.

3. Game development for own startup company - I would be a fool not to include the most important of time consumers a programmer occupies his time with. The average time needed for this is 0-8 hours a day. The reality is, working for someone else as a programmer is a waste of talent. Most programmers know this. That is why they all have their own pet game project a-brew. A programmer without one of these is just an analyst.

Before any programmers out there start complaining about an item I missed, keep in mind that this list is not exaustive. If there are any other time consumers which need to be added, feel free to comment!

Friday, November 10, 2006

Javascript + Blogger != DHTML Bliss

I'm writing you today to tell you about my recent foray into Blogger template coding. I was at work today tasked with the demeaning chore of QA testing. You see, today I found out that one of my company's web application products, which I had been working on, was going live for a big client on Monday. We hadn't even finished all of our bug fixes when I was told at lunch that we needed to smoke test the application. I was new to the term 'smoke testing' as it applied to software. Back in my avionics technician days, we used the term 'smoke checked' to describe what we did to a piece of avionics gear which we fried. I didn't like where this was going.

Things got a lot better when I was then told 'smoke testing' this application normally takes 2 full days for 2 testers to complete. Well, it was noon on Friday and I was planning on actually doing something this weekend. So much for that idea.

Back at my cubicle, I opened the document containing all of the 'smoke testing' procedures I needed to perform. After losing all interest in testing 15 minutes later, I began thinking about my blog and the cool little floating DIV which I was excited to add to it. You see, I had spent most of my time yesterday afternoon to creating this floating DIV as a side project for the company app I had been working on. It worked great in that app, so I was sure it would work fine on Blogger.

I've never prided myself on being always right. After spending a few minutes adding the javascript and html to the blog site, I tested it. In 'preview' mode it worked beautifully! I was full of joy! The little box which represented the DIV centered itself in the middle of the window. When I scrolled down, it floated down and centered itself. When I scrolled to the side, it recentered itself again. What a fun little gadget!

The published version, however, was far from adequate. Instead of centering itself in the window, it centered itself in the entire body of the page and stayed there. How could this be? How could some simple javascript which worked fine in another application, which worked fine in the blogger 'preview' mode after editing the template, fail once published?

I got on my IM and messaged Dan. I told him the world was coming to an end because Blogger was being evil. He told me he had similar problems with his page layout and said it was the blogger banner on the top of the page which was to blame. Indeed, Blogger does something to the page when publishing it. It adds the top banner and seems to do other things which interfere with the element hierarchy of the page. I figured I would save this problem for when I got home since I had so much retard work ahead of me.

Later in the evening, after getting home and porkin' out on some steak, I researched the issue. The problem was simple! The hierarchy of the page DID get modified by Blogger. Let me show you what was goin' on. Here's a portion of my javascript which wasn't working after being published:

var lockMsg = document.getElementById("FloatingDiv");
var viewHeight = document.body.clientHeight;
var viewOffset = document.body.scrollTop;
var viewWidth = document.body.clientWidth;
var viewOffsetLeft = document.body.scrollLeft;


Here is the version of code which worked:

var lockMsg = document.getElementById("FloatingDiv");
var viewHeight = document.documentElement.clientHeight;
var viewOffset = document.documentElement.scrollTop;
var viewWidth = document.documentElement.clientWidth;
var viewOffsetLeft = document.documentElement.scrollLeft


As you can see, the document object which I had referred to in my initial code was nested one level deeper which caused the document.body.scrollTop attribute from not being available.

After making this fix, I was able to get the floating DIV to work properly. If you haven't noticed, I have placed the floating DIV on this page, floating near the middle of the window. If anyone wants to complain about how plain it is, go for it. I'll need the motivation if I'm going to be changing it. (If any readers have any questions about any of the code or topics in this article, feel free to ask! You can email me at jayndan.blogger@gmail.com).

For now, however, I am off. Stay tuned for more!

~Jay~

Wednesday, November 08, 2006

Introducing Dan!

As you may be aware, this blog is called 'Programming with Jay 'n Dan'. Because of this, I figured it might be a good idea to introduce Dan. I won't get into too many details at the moment, I'll let him do that for you later. For now, just know that our professions are similar and he shares some of my belief in what our jobs are really for. To demonstrate this, check out a recent IM dialog of ours at work:

[16:47] nevarezz: well dan, i just finished a nice long segment of code writing... and now the nightmare begins...
[16:47] GhostInAK: debugging?
[16:47] GhostInAK: or explaining how to use it?
[16:47] nevarezz: the wonderful world of errors
[16:47] nevarezz: yes debugging[
[16:47] GhostInAK: lovely.
[16:47] GhostInAK: I'm at the same point.
[16:48] nevarezz: i built an asynchronous handler for this webservice...it looks so pretty and elegant... it doesn't need to run yet. i'm sure its fine
[16:48] GhostInAK: code that doesn't run is guaranteed to be bug-free.
[16:49] nevarezz: well spoken my friend
[16:49] GhostInAK: async handlers are fun.
[16:50] nevarezz: i think i got off relatively easy because the caller doesn't need any of the return values...any return info is just getting logged
[16:50] GhostInAK: I just got done writing another file reader (for DEMs this time).. a DEM file is aligned on 1024 byte boundaries.. but the data structures within the file cross the byte boundaries.. crazyness. Why can't I find a file format that makes sense around here?
[16:51] nevarezz: lol
[16:51] GhostInAK: Ah, sweet. so in yer case garbage in doesnt nessecarily produce garbage out :)
[16:51] nevarezz: yup!
[16:51] nevarezz: just a tidy little file
[16:51] nevarezz: that no one is gonna ever use
[16:51] nevarezz: lol
[16:51] GhostInAK: *smiles*
[16:52] nevarezz: i should just make the logging function into comments
[16:52] nevarezz: cuz that's all it will be good for
[16:52] nevarezz: lol
[16:53] GhostInAK: heh.
[16:53] nevarezz: oh wait, i'll put the logs in the registry
[16:53] GhostInAK: *eyes you suspiciously*
[16:54] nevarezz: nothin wrong with a bunch of garbage in the registry
[16:54] GhostInAK: that'll work as long as you write a pointer to each log entry into the disk's master boot record.
[16:55] nevarezz: INGENIOUS!!!
[16:55] GhostInAK: Hows your Mexican web farm goin?
[16:56] nevarezz: there's a huge crop down here
[16:56] nevarezz: i haven't started pollenating yet
[16:57] GhostInAK: well git on that man.. I hear the latest games are being written to take advantage of the processing power a large farm can provide.
[16:57] nevarezz: i think i'll do it with subliminal hypnotic technology
[16:57] nevarezz: they won't even know they know what they know
[16:57] nevarezz: or why they seem compelled to find someone else to tell it to
[16:58] GhostInAK: heh. You gotta attract your mexicans first.. I hear they tend to congregate near orchards, avacado groves, and vineyards..
[16:58] nevarezz: and construction projects
[16:58] GhostInAK: ah yes.
[16:59] GhostInAK: ooooooh!! Buy a bus! Mobile Mexican web farm! Like a laptop.. but cooler.:)
[16:59] nevarezz: DUDE!
[16:59] nevarezz: that would rock
[16:59] nevarezz: i could have a wide area network of busses
[17:00] GhostInAK: then I'll get a bus.. and we can have like a lan party man.. on the fuckin beach! Yeah!
[17:00] nevarezz: the mexicans inside could throw beans with engraved messages back and forth at stoplights and when passing
[17:00] GhostInAK: sweet!
[17:00] nevarezz: dude, we should write a book on this stuff
[17:01] GhostInAK: no kiddin! We'll be the KINGS of WAN (Wetback Area Networking)!!