Creative Commons

2007-08-16 07:32:33

The Case for Absolute Positioning

This is an argument I get into every so often with people. Whether, in your graphical applications, whether they be fat or web apps, to position your elements relatively or absolutely. Now, I'm not talking about every single element. Just the ones where it makes sense.
Take, for example, a web application. You have certain elements which never move, no matter how small or large the client's window is. Things such as your header graphic, header text, link menu, etc. Those are always in the exact same place for every browser each and every time you view the page.
Now normal practice would tell you that to achieve the best results, you should use relative positioning. That will take into account all of the factors that are out of the control of the developer, such as browser text size. And it would be great to be able to always use relative positioning. But some things are just out of our control. Like what, you ask? Standards.
If only the web conformed to standards. Well, not so much the web as the browsers people use to surf the web. Firefox does things differently than IE7, IE7 does things differently than IE6, IE6 does things differently than Opera, Opera does things differently than Safari, blah blah blah. Especially in the realm of CSS, each and every browser does things differently. Most web developers know this, hate it, but accept it. They design a page, using relative positioning, and it looks great in Firefox. They go to test it in IE6 and it's foo. Then they open it in IE7 and it's a different kind of foo. Why?
It's because of these inconsistencies that relative positioning for certain items just isn't an option. You will spend more time hacking your CSS and XHTML to try and make relative positioning appear the same on all browsers than you will creating your entire site. Even though this is the biggest pain en el asno, it wasn't what sparked me to write this article.
On Tuesday, I was at lunch with my friends from my previous employer. Somehow the conversation came to Mono and my EmailSender program. I was complaining about how Mono won't run my program because of one image. Apparently Mono hasn't implemented the set_ImageKey method yet, so the whole thing crashes. So Dave suggested that I write the GUI using GTK. Alas, I have tried that. I can say, with absolute certainty, that GTK is the worst language every for writing GUIs. Why? Absolute positioning doesn't exist, at all. If you want a button to appear in the center of your window, you have to first create vboxes and hboxes, dividing your window into parts, then place the button in the cell that is in the center of the window. Seriously?!?!?! If that wasn't enough of a load of crap, I actually took the time to recreate my program using GTK. I spent hours slicing up the window so that I had a cell, in the correct spot, for each and every element I had in my program. Finally, I ran the app and what do you think happened? If you said that it worked flawlessly, you are sadly mistaken. Apparently aside from not supporting absolute positioning, the creators of GTK also screwed up the automatic sizing of the h and vboxes. Instead of taking the height of the element placed into them, they became smaller. That's right, the GUI looked fine in the GTK designer, but when I ran the app, each and every element had the bottom half cut off because the stupid h and vboxes couldn't figure out for themselves that if a button is 20px high, maybe it should be 20px high too. SERIOUSLY!!!
*BREATHE* I'm ok now. So there it is. Not everything should be positioned absolutely, but a lot of things should, despite your better judgment.



2007-08-16 17:49:58

Anonymous says...
Definitions: Mono 1.2.3
Methods that have been implemented:

2007-08-16 17:55:16

Anonymous says...

Post a comment!