Archive for the ‘technology’ Category

When technology fails

Thursday, June 1st, 2006

Sometimes it’s really weird how things coincide. I read Joel’s Lazy Programmer, Didn’t Handle Exception and started noticing these daily.

A few days ago I bought tickets for the local theatre online. I never print out the receipt with the codes because I have a card that allows me to get the tickets on a ticket machine. Unfortunately for me the machines were out of order. I waited in line but the clerk told me she can’t really give me the tickets if I don’t have the codes. Yes, she knows it’s unfortunate the machines are not working but she really can’t give me the tickets. Since I was not to keen on accepting this fact she had to write the tickets herself.

I sometime think its funny when watching movies that some companies and/or government agencies have such contingency plans in place. When something like this happens I really hate it that some don’t. Fortunately Slovenia is small enough to usually get things right anyway.

What people don’t know is that all this is a part of user experience. There’s nothing wrong to send the people to a clerk when machines break down if they know why and can explain and help you. Sadly this is not a priority in our little country. Still.

Javascript compare

Thursday, May 18th, 2006

Today I found something in Javascript that just doesn’t make any sense. Ok, maybe some other things don’t make sense either, but I think this one just beats all of them.

Let’s say we have a string and a number:

a = "1";
b = 1;

Now we want to compare these:

alert((a>b) ' : ' (aa) ' : ' (b==a));

Both will give you ‘false : false : true’.

If we change a to “2”

a = "2";
b = 1;

we get a ‘true : false : false’. We’re still OK.

Now let’s change a to “a”

a = "a";
b = 1;

The weird thing is we get ‘false : false : false’ on both alerts.

In typestrict languages you’d get an error. Or at least you should. In php you get a ‘false : true : false’ and ‘true : false : false’ which would mean they decided that all strings are smaller than numbers. This is weird – if you make b a string “1” the return values change – but at least they made a choice.

For what I can comprehend Javascript casts both values to int and I can understand that. The core of the problem is obviously with the NaN value. What I can’t understand is how something’s not smaller, not bigger and not equal at the same time? I’m sure someone can explain this…

Frameworks in the future..

Sunday, May 14th, 2006

We recently had two workshops on AJAX and in the second one my co-host presented some JavaScript frameworks and we got into a discussion about when we’ll start using one of them. It seems that it was not a question of if but of when. I should point out that both of us are proficient in JavaScript and are not the primary targets of frameworks.

A few days later Eric posted Flummoxed by frameworks that started a huge debate about it (he also posted a later explanation). Yesterday I was also listening to Dustin’s episode 12: YUI Library Discussion about the Yahoo! User Interface Library.

What I got from all this was a weird feeling about frameworks. I can’t decide whether I like them or not and why. I don’t especially like any single one of them. Like any other advanced developer I have my own bunch of methods/functions/objects that I regularly use and copy around. This code evolves automatically as I find bugs or need more features. Frameworks on the other hand do this with a plan. Or so it seems. Hopefully the developers behind them are strong enough to fight the feature requests coming from noobs to keep the core frameworks small, simple and above all understandable. Even though some say bandwidth is almost free nowadays.

After a whole day of pondering I think I like the idea but probably not the hype and the implementations that more than anything frustrate me. I’m off to write my own framework.

Semantic CSS

Monday, May 8th, 2006

Today as I was driving home from work I was thinking about ways to accomplish margins in CSS. This was probably due to a code inspection of a certain CSS file I was doing a few days ago that was ugly as hell. It made me think that maybe the number of WYSIWYG/clickety-click editors of CSS/HTML that produce DIV layouts is reaching the point where this needs discussing.

In my opinion a good HTML developer is one with at least a few years of experience doing various web sites on various platforms. This is due to all the things that can screw up a layout when things go off the chart either via user-generated content or by the constant redevelopment. You just can’t learn all the quirks and good practices through reading.

Up untill now it was really simple to figure out if somebody was proficient in CSS – they were using DIV layouts. Now you just can’t. And there are so many ways to create a layout that are just plain wrong and some people don’t know why. I’m not saying I always do but I think all the years of experience help.

So back to the beginning – let’s take a list item element. There is a bunch of ways you can change it’s margins. Let’s first look at the left margin.

  • text-indent:10px;
  • margin-left:10px;
  • padding-left:10px;
  • position:relative;left:10px;

Now let’s look at the top margin.

  • margin-top:10px;
  • padding-top:10px;
  • position:relative;top:10px;

If you add more elements to the mix you get even more options and usually more confusion.

If you’re proficient in CSS you should be thinking of other ways to do this. If you’re not you should know that ‘margin’ property is the way to go and that ‘padding’ property is the only way to add the padding. It’s really the same discussion as why an unordered list with items should be ul-li and not a p-br. And I hope you do know that one…

Changing the way we change websites…

Friday, May 5th, 2006

A while ago Marko wrote about reusability of css based designs. I didn’t agree with him fully but had no idea how to explain/prove it.

In the times of table layouts the process od redesigning a site was actually (at least) three things. First the content was restructured and some of it written again (the sitemap). Then the layout was changed to reflect the new structure and to better fit the content (the wireframes). At the end a façade was made for reflecting the latest trends in ‘webdesign’ (the design – or is there a better word for it?). Even if it was a three way process it was rarely done by three different people – ‘webdesigners’ did almost everything themselves. Since this was quite a lengthy process it was also expensive and some corporate websites changed once every three (or more) years.

Now it seems things are changing for the better. With a DIV layout, CSS based designs and a strict separation of layout and content we can actually split these three into separate stages. The strict division of these stages gives us the posibility to focus our work on what it really has to achieve. It’s true that you cannot use the whole 100% of the other parts but being able to keep 80% is good enough.

About a week ago I found out about two ‘design’ contents and the one Slashdot is holding was interesting because it was about proving a point – you can change the façade without changing the layout or the content. I did the whole thing without changing a bit of HTML (with a bit ugly CSS, would be nicer if a few lines of the code were changed).

I think this way of thinking will settle in and more and more changes will include only one of the three stages. Hopefully they will be based on user testing and/or usage data…

WordPress hates developers

Monday, April 24th, 2006

Another one in the series of “… hates developers” is WordPress. I’ve been messing with it since I installed 2.0 to power this blog. I’m not happy.

As the title already states I’m not saying that WordPress is bad for the common visitor or even the common user/author. Yes, it has some problems but they don’t even come close to what it has to offer to the power user. If you’re trying to create a plugin that does something they didn’t expect you’re out of luck. That, or the documentation sucks as hell.

To elaborate I’d like to share a bit of it’s code from template-functions-general.php:


function get_post_time( $d = 'U', $gmt = false ) {
	global $post;
	if ( $gmt )
		$time = $post->post_date_gmt;
	else
		$time = $post->post_date;
	$time = mysql2date($d, $time);
	return apply_filters('get_the_time', $time, $d, $gmt);
}

As you can see getting a time when you’re not in the main post loop (that sets the global $post) is a bit weird. You have to set a global variable post and then run this thing. You should probably know that this is not the method that is usually called from the templates – that’s the_time that calls get_the_time with a filter, get_the_time retrieves the time_format setting and it calls get_post_time.

Another great thing is getting an author of the post. I gave up end wrote my own sql statement. I don’t like it and if there’s another way please tell me – template-functions-author.php doesn’t tell me anything useful. The global object $authordata is just too much.

I understand that this kind of code gets into version 1. I can’t understand how it gets into version 2, especially when they said they improved abstraction in this version. OK, I can understand the focus – first the users, then the writers, hopefully now the developers. So my proposition for version 3 is a complete rewrite of the backend to something more API-ish so we (plugins and the core) can use the same built-in API for most of the stuff.