Archive for May, 2007

IE on Ubuntu

At first, I was hesitant to install IE on Ubuntu.  Basically, I didn’t think I could trust it.  But after spending hours and hours of development time waiting on my windows virtual machine to do anything in IE, I knew I had to try it.

IEs4Linux work great.  I only use IE6, and it is great.  At first glance, it seems to work exactly like IE on my virtual machine, except it runs as fast as a normal desktop application.  This is definitely a tool any web developer who runs Linux should use.

If I notice any inconsistencies between IE on Linux vs. Windows, I will be sure to post it here.

More Active Record Features

It has been a while since I have written about, or coded, my Active Record implementation. Basically, I have had too many other things to work on to enhance the functionality of an already working, albeit very beta, design. But, that doesn’t mean I haven’t been thinking of all the features I want to add to it.

For many applications, the date created and date modified information for data is very useful, but annoying to set. Since Active Record abstracts all access to a database, these fields can be set easily and transparently. Many other implementations of the Active Record object already support this, so its not a new feature, but definitely a needed feature. The main issue is what timezone the server is in since NOW() doesn’t return GMT. It’s obvious that GMT is the preferred storage format of this data, so maybe passing a GMT date string from GMT is best.

Another feature that I just thought of is soft deletes. Basically a soft delete is where the data isn’t actually deleted, but a flag is set to show that it is deleted. This is very useful if you need to keep old data around for restores, or if you just want to have a record of everything. One of our new hires MikeT brought it up to me since his project has a soft delete requirement.

Hopefully I can get these added into my implementation fairly quickly since they are so simple.  Even though features like this are just the tip of the iceberg, they are crucial for creating a viable Active Record design.

The buggiest PHP function

Well, its not really PHP’s fault. array_search is misused by developers more than any other PHP function I have seen. Just today, I found two bugs caused by misinformed developers using the function. I myself am also guilty of using this function incorrectly.

The problem lies in array_search’s return value if the needle isn’t found in the haystack. If the needle isn’t found, array_search returns false. In my experience, many other libraries return -1 in this case. Nevertheless, false and 0 evaluate to the same boolean value, which is where the problem lies.

For example, the following code will not work how you might think:

while(array_search($value, $array)){
....
}
 
while($key = array_search($value, $array)){
...
}

In the first example, in_array should be used for simplicities sake. In the second example, you must use the identical comparison operator (=== or !==). So, when using array_search, be careful not to make any wrong assumptions.

Joel Predicts the future regarding Microsoft

The other day, Kevin sent out an article written by Joel Spolsky. To make a long story short, he discussed how Microsoft is shooting itself in the foot by not maintaining backwards compatibility. VB.NET isn’t backwards compatible with VB6, .NET 1.1 isn’t backwards compatible with .NET 1.0, etc.

When I first read the article, I didn’t entirely agree with him.  Most of the newer technologies Microsoft is developing are really cutting-edge, from a programmers prospective. When I first coded a .NET application in C#, I thought it was the best thing since sliced bread.  .NET is a great library, much easier to use than the Win32 API.

Literally the day after I read the article, Pat came up to me and asked if I was a Microsoft Office guru. I said no, but I could probably answer his question. Here is the question:

I can’ t open the Word documents Tricia is sending me. She says whenever she saves it, it is adding an X to the end of .doc.

Then it really hit me. Joel had predicted the future. His article was written in 2004, and in 2007 I see what he meant.  Even though he is talking mainly about API’s, I think it carries over to this document type issue. The Word .doc format has been around in its current form for a long time, since Word 97 I believe.  The .docx format is probably better from a programmers standpoint, but not from a users standpoint.

It will be interesting to see if this mentality continues to persist as Microsoft faces more competition in all areas of their business.