Nola Stowe's blog

Testing with Selenium TestRunner

I know, I know its been two weeks since I posted. . . but I hope this makes it worth the wait!

I've looked at Selenium a few times but just couldn't fathom how it could possibly work -- and with all javascript?? I went to a Ruby "HackFest" here in my beautiful city of Chicago and met one of the developers of Selenium , Jason. He gave a demonstration of Selenium testing itself and I saw how it worked, but how do I get it to work? As it turned out, in my traditional fashion, I was making it harder than it really was.

Perl vs. PHP - Datatypes[arrays|lists|hash|map]

I've made a few friends recently who are ultra Perl geeks (Yes, you know who you are. Andy, Liz and Brian!) and they are rubbing off on me. I learned Perl a little bit, about 6 years ago when I first started web programming but I didn't know any Perl programmers so I had nobody to pester with questions. I always said that Perl was cryptic so Perl Elitists could show off their l33t ski11s. But I've found it's not all that bad…

I know PHP so well, that it helps my understanding to compare Perl to php (Don't flame me Perl folks! I'm not promoting one over the other, just comparing and contrasting).

HTML Helpers - Ruby Wannabes in PHP

I've gone back and forth on the idea of using ALL html generation functions to hammering it all out in a template like Smarty. Templates are nice, It sure is nice to use functions. I was looking at RoR and saw these HTML helper functions. I thought, hey I can write them in php. (Yeah to all you php hating ruby folks, this may be an effort in futility, but thinking how to implement some of these things in PHP helps me understand the concept, like my MVC articles)

Implementing just a few… Here's what I came up with:

Test, please.

On quite a few of my projects, I need people other than myself to test it. Projects that are more complex than simply displaying a list of phone numbers. Perhaps I have not looked in the right places, but I have not found much in the way of methods of getting people to test applications. I'll explain some of the ways I've tried and their result.

Database, Field and Tables - Naming Conventions

Recently I have been working with Mantis, a php bug tracking software. I noticed that all tables were named something_table. And I got to thinking, what are some good standards to keep in mind when naming databases, tables and fields. I have changed my mind a few times in the past on naming things, but this is my current thinking on the subject.

Caveman PHP Debugging

Certainly it's possible to have nice debugging tools for php (ZEND has one), unfortunately I have not had the experience of any so I will tell you how I debug php - caveman style!

Poke it with a stick
Sometimes, you aren’t sure if the code is getting to a certain line. For quick checks I put

print "here";

That’s fine until I get interrupted or go home only to come back the next day and wonder, huh? where did I put that line??

Stupidly Easy MVC in PHP or "We don't need no stinking framework!" (Part 2)

If you haven't read Part one, go do it! It provides the background for these classes.
In Part 1, I explain my base classes: MVC_Controller, MVC_View and MVC_Model. For my simple links application I extend the model class and the controller class. I did not need to extend the view for my purposes.

As I said before, the "action" variable is actually the name of the method you want to run. I listed the actions previously that I will need (planning ahead, what a concept) so it makes it easy to implement now:

Stupidly Easy MVC in PHP or "We don't need no stinkin' framework!"

One day I sat, faced with this huge 'god' class that managed view, edit, add, delete for two components in one page. There was no value to having all that in a class, other than having a nice neat little "package." I considered breaking it into two classes, one for each component (which was really in the end one) but keeping the same basic methods … ehh, that didn't sit too well with me. I wanted to use templates, make it super easy to update when the powers that be changed their mind or wanted to add something. Then ... after a day of staring it and it and making some notes -- a light bulb went off in my little head. I fired up my laptop, opened some ruby files I had made. Looked at a "controller" file... ok... then looked at a "model" file... ok... then looked at a view file... Ah ha! Bingo.

Not wanting to start a whole new honking framework package (although for the first time I had a fleeting thought, HEY I can start a sourceforge project!!!) just for this one small app... I didn't want (and probably would have a hard time getting approved by sys admins) a framework like Solar, PHPOnTrax, CakePHP or Cerebral Cortex (whew! did I miss any?). But, this was so stupidly easy... and I just had one little application..

Data Types - PHP Vs Ruby (Part 2)

Ruby's types are actually objects with methods, which is different than PHP's primitive types. At first, I thought I'll have to do something like

age = Number.new(28)

Not so, in fact the number classes don't even have a new method. Declaring a value to be a number is:

age = 28;

I'm sure there's some fancy word to describe the magic that happens. I like automagically.

Data Types - PHP Vs. Ruby

In conversation with a fellow PHP person now doing Perl, he asked… how does Ruby do types?? And I thought I knew how to answer him, but then when I opened my mouth I found I didn't have the words.

PHP is not a strongly typed language. You can assign $foo an integer, print it (even though it does not contain a string), assign an array and so on. PHP doesn't care.

However, if you want to be certain of the type in a variable there are a few functions to help you out.

settype($var, [type]);

example, to make sure these types

settype($foo, "bool"); // also could use "boolean"
settype($bar, "int");