my life

day to day

Archive for July, 2006

PHP5.1.4 Segfault Woes

Saturday, July 15th, 2006

For the last few days I’ve been battling a nasty bug that remains elusive. What makes it so difficult to track down is that it crashes at totally random spots on a vanilla PHP setup (no special PECLs). With more than 10,000 lines of highly objectified code and no decent debuggers, this is a real challenge that I’d be glad if it just solved itself.

 

add to del.icio.us    add to technorati favs   email this

PHP5 OOP must haves

Friday, July 14th, 2006

We’re always taught when learning OOP to be a strict as possible when declaring methods/members as public, private and protected. For some reason though, when programming PHP we’re in this mode that since it’s a scripting language “let’s not adhere to better practice”. Well, atleast I kind of fall for this and going by all of the other peoples code that I’ve read it’s not too uncommon. The project I’m working on has reaffirmed that there is no excuse for sloppy programming.

When writing OO PHP5, always start by making all properties private or protected. Declare the overloading/accessor methods for __set, __get, and __unset. Throw as many exceptions as possible and things will debug themselves with little or not effort on the programmer.

Asside from protecting your privates, this method aids in profiling your code too. Since by moving your assignments and gets into a function call, they can now be counted by a PHP profiler such as apd.

 

add to del.icio.us    add to technorati favs   email this

Full circle

Thursday, July 6th, 2006

All those years in college gave me good preparation for what laid ahead. Little did I imagine that all those nights spent at Starbucks studying would be a foreshadowing of my life to come—telecommuting. It’s a skill that requires obsessive concentration and the ability to filter out ambient distractions.

 

add to del.icio.us    add to technorati favs   email this

Wikify Wordpress

Monday, July 3rd, 2006

Test a search for linux.

add to del.icio.us    add to technorati favs   email this

404 Mishandling

Monday, July 3rd, 2006

Both gallery2 and wordpress2 have shotty support of 404s when dealing with permalinks via apache2 rewrites and aliases. This becomes a big deal when you want spiders to index your site and they disappear as soon as they realize you don’t support 404s (b/c you appear to be a spider trap). I’ve read numerous posts on the topic regarding Wordpress and they say they’ve fixed it in the latest version which I’m running. Perhaps I’ve misconfigured things, but through careful tracing of execution I’m skeptical. As a result, I’ve created a plugin that I call “Fix 404″ to deal with the WP issues. Next, I need to figure out what the problem is with G2.

add to del.icio.us    add to technorati favs   email this

Wordpresses Letdown

Monday, July 3rd, 2006

Wordpress quickly became the blogging software of choice for bloggers everywhere, unseating MoveableType the previous title holder. It did this much because MT was too difficult for most to use. It’s templating system and class structure was much more elaborate and thus complicated. It didn’t help too that it was written in Perl, a programming language with very concise sytanx like $foo =~ /[Ff]uck[!].Off?/ able to scare off all but the most bold programmers. Wordpress on the other hand, can be picked up by anyone with limited programming experience in an afternoon’s time. The problem is, however, that the developers of Wordpress are unfortunately amatures themselves, with little or no concept of object oriented (”OO”) design. Wordpress 2 is technically OO, but the class structure is a joke and essentially one big container. There are a handful of mega-classes like WP and WP_Query, which drive the entire application. All do a fine line of bluring the difference between function and object oriented code. Everything else is functional and relies on a global variables such as $wp, $wpdb, and $wp_query, which if anything should be a singleton instances, local in scope. Trying to extend anything is impossible without modifying their code. Their idea of templating is doing “includes” on different php files with formatting and additional logic. There’s no seperation between the presentation layer and the data layer.

Bluring the line b/w OO and functional programming, look at WP::query_posts

function query_posts() {

$this->build_query_string();
query_posts($this->query_string);

}

and the global function query_posts

function &query_posts($query) {

global $wp_query;
return $wp_query->query($query);

}

I don’t mean to lambast the Wordpress developers personally, but this is just humorous. It doesn’t utilize any constructs of PHP designed to handle this kind of thing (E.g. statics and singletons) — and that’s only if you support their overall flow/execution. Granted static methods were introduced in PHP5, but static variables have been around since PHP4.

add to del.icio.us    add to technorati favs   email this

Acrobatic Martial Arts

Saturday, July 1st, 2006

add to del.icio.us    add to technorati favs   email this