Post-Anything

May 26, 2008 Leave a comment

My undergraduate degree was in history.  As credentials to build a profession on, its a pretty useless major, unless you want to teach history.  But one thing it gave me was a perspective on the flow of time in the human story.  Everybody always thinks that now is the ultimate stage of development.  Modern is wonderful.  Woops, I mean post-modern is better.  Oh, no, I mean post-post-modern is everything we ever needed.  Wherever we are now, if we’re inclined by temperament to be content we have reached the pinnacle.  If we’re inclined to optimism, now is messed up but surely truth and enlightenment are a stage or two down the line.  If we’re skeptics then whatever we did yesterday was definitely wrong, we’re not that much better today, and tomorrow is doubtful.

When we call something “post” something else, generally its a reaction–a rejection of whatever was in the something we are now post.  It is the plight of youth to react to whatever the generation before thought was great.  It is the plight of the young, bright professional to think that the voice of experience has stagnated.

Not really being the voice of youth any more, I have come to understand that my views on how to do things aren’t the pinnacle of perfection any more than the problems built into previous generations of methods were perfect.  The methods of tomorrow aren’t going to be perfect either.  While technology develops, people basically have the human capabilities that they have had for the past several thousand years, and unless we hit a technology singularity (or maybe even then, just faster) or the world ends we are about the same as the people a couple of thousand years from now.  Human nature, human creativity, human relationships, all work about the same over time.  And these are what our lives are made of, regardless of whatever the current hype.

Given that work is done by humans, and humans tend to be about the same as they have always been, why does it seem with each generation that the new methods for getting stuff done are so much better than what has gone before?  Is this just illusion?  Is Agile really better than TQM and the “tired” methodologies that went before?  Is post-Agile an improvement?  Total Quality has a lot of obviously valid points in retrospect.  The Theory of Constraints is mostly just common sense applied to processes.  To a great extent, the heart of Agile (as exposed by the Agile Manifesto) is just a reminder about the human core of all processes.  Here’s a guarantee:  our children will think Agile is nonsense, and whatever is the new fad is incomparably more effective.  Our grandchildren will be post-whatever our children are.  And they’ll be right, but at the same time they will be wrong.

I’m convinced that methodology itself mixed with human nature plus time is the main problem with methodologies.  Agile isn’t any different, as successful methodologies go.  It reminds us of the important stuff at the heart of processes:  people getting things done for people.  It reminds us that it is the people who are important, and that trust matters.  This is good stuff.  Important stuff.  Then, being creatures of habit, we formalize the rules of our methodology.  We try to make it reproducable.  We write books so that other people can do it too.  We tell them with confidence that if they do it like we did it, they will succeed.  If they don’t succeed that means they didn’t follow the method.  Bull.

What is successful about Agile isn’t the methodology.  Its the philosophy that processes are about people doing things for people.  Its the reminder that we should aim for the goal.  When the philosophy succumbs to the habits, the truth underlying its success dies.  The method becomes king rather than what made it successful in the first place.

Here is what makes Agile successful:

  • People matter more than tools and processes.
  • Software should work, and it should accomplish the goals for which it was created, as quickly and effectively as possible.
  • It must accomplish the real goal, not my conceptualization or explanation of the goal.

Methods that enforce these concepts are successful, at least until the method takes over and the concepts are buried.  Processes stagnate, because humans are creatures of habit.  Habit isn’t bad.  It helps us reproduce good behavior.  But it can also kill us when we stop examining.  New processes, if they are any good, re-remind us of the things that matter.  They strip off the stagnation and bring us back to the things we were reminded of when the old processes were new.

Post-Waterfall is a very good thing.  Post-Agile is fine.  Post-Post-Agile will probably be fine too.  Maybe it will be a reaction against the fuzziness and a re-injection of more formality.  If so, it will be because people got too lazy with post-Agile development and devolved to ineffective chaos.  We’ll cycle around and figure out that whatever went before was all wrong.

At the base of it, its still about applying technology to make people more effective in reaching real goals.  Its the people and the goals that matter.  Pick a methodology that enforces these critical concepts, and do it until it becomes habit, then shake vigorously and repeat.  Do that until that cycle becomes habit, then do something else.  But always remember that its the people and the goals that matter, not the technology, and not the processes themselves.

Categories: development

Trying Ubuntu 8.04

May 24, 2008 3 comments

I’ve been using Suse (and OpenSuse) for years, ever since moving off of RedHat when they started Fedora.  Other than a couple of Gentoo detours, RPM based distributions of Linux have been where I have lived since RedHat 6 point something.

I have been having some problems with my laptop (running OpenSuse 10.2) and it got to the point that I thought it might be easier to get a clean install than figure out what was causing my various problems.  That sometimes happens when you get a year and a half of messing with stuff accumulated.  You can’t easily roll back what you can’t remember you did.

So I’ve been waiting with anticipation for OpenSuse 11.  But I got tired of waiting, and this weekend I decided to try Ubuntu, which I’ve played with but haven’t actually used.  This is quite a change for me.  I’ve worked with Debian servers from time to time, but not by choice.  I have also been using KDE for a very long time (starting with KDE 2).  For the first time in recent memory, I’m moving to Gnome.  I might end up changing back to OpenSuse and KDE when it is released, but this will give me a month or two of spending the ten hours a day I spend on my laptop finding out what the other side is really like.

Ubuntu installed very nicely.  The installation process doesn’t seem as flexible as OpenSuse.  I missed OpenSuse’s easy package group selection.  But overall, I was fairly impressed.  Within just a few minutes I had a shiny new Ubuntu desktop.  Of course, it didn’t use my external monitor, and the display resolution it started with stunk.  But a quick install of the binary drivers (not installed by default because they aren’t “free” in the sense that they don’t come with a open source license), and a little configuration tweaking, and I had my dual monitor Xinerama setup working nicely.

I am not a fan of sudo, at least on boxes on which I am the only user, but I think I can get used to using it.  I’d rather open a terminal and su to root.  But its not a big deal, I’ll adapt.  On boxes where there are multiple people who might touch system wide settings, sudo is very nice.  That just doesn’t apply to my laptop.

Wireless, sound, and all of the rest of my hardware just worked.  Adding packages was very easy, and everything worked very nicely.  While there are some things I like about smart over synaptic, I’ve used synaptic before and it has come quite a distance since I last worked with it.

One thing that really impressed me was adding a printer.  The system-config-printer tool found my printer on the network (I print directly to the IP address using CUPS) and got it set up and configured almost without intervention, and it was about the easiest printer setup I’ve ever seen.   Way easier than it would have been in Yast (at least on OpenSuse 10.2), and of course way easier than Windows does anything.

I prefer administration tools that put everything in one place for you, rather than having to hunt for the right tool to tweak settings.  So I like the approach of the KDE preferences tool and Yast better than the “What was that thing called again” search for the right tool.  Some of that might be familiarity, but Ubuntu/Gnome could do a better job of streamlining the preferences process.

Overall, I am impressed.  The system install, adding software, getting things configured, and getting started using the new setup was very quick and easy.  I think just about anybody could do it.  Having recently struggled through trying to get Windows 2003 servers working properly, Linux definitely beats Windows, and I would not have any trouble at all recommending Ubuntu to anybody.

Some of my easy conversion might be because I’m not exactly new to Linux, and I knew going into it what some of the differences were going to be.   There are also a couple of non-distro related factors that make migration easier than it used to be.  I have a handy external USB hard drive.  So backing up my home directory so I could repartition my laptop was simply plugging the drive in and dragging the home directory over.  The hard part was waiting until it finished before I started messing with it.  When I got Ubuntu installed, I just dragged my stuff back to my new home folder.  Also, so much of my work is on Google, or in an svn repository, or other places out there somewhere in the cloud that saving the actual stuff on my hard drive is much less critical than it has ever been before.  My laptop is much more of an interface for stuff out there somewhere than it is actually used for storage.

If I change back, or if I find out things that make a difference, I’ll post them here.  I’m not sure how much I’ll like the differences in editors, terminal, and so on.  Only time will tell.  At the moment, it looks like my experiment might turn out to be a little boring, so I’ll stop talking about it for now.

Categories: linux, ubuntu

Getting more done

May 21, 2008 Leave a comment

I was delighted to see the announcement that Zend Framework is partnering with Dojo.  Life will be easier.  I like Zend Framework.  I like Dojo (although I’ve used jQuery on some recent projects).  What could be better?  Time from idea to working solution will be shorter.  As a result, customers and users will say “Wow, how’d you do that?” and get back to working more efficiently and in ways they couldn’t before, quicker.  That’s good stuff.

Categories: javascript, PHP Tags: ,

Did you feel the world shift?

April 9, 2008 Leave a comment

When I saw the information on Google App Engine, it occurred to me that we are witnesses to a paradigm shift. It isn’t just about Web Services and Services Oriented approaches to them. It isn’t just about Facebook and social apps. Its a different way to look at how we build and provide services in general. Its a different way to look at data and integrating it with services. Its a true shift, and we’re just at the beginning.

Since we are just at the beginning of this, its hard to see what it will really look like. We have the start of it in Google App Engine (and some of Google’s other services), and Amazons Web Services, and in IBM’s AlphaWorks QEDWiki. But it isn’t just about hosted services, or about mashups, or about APIs. In fact, I’m not even sure exactly what it is, or how to think about it. But get ready. Its going to be different from what we’ve ever done before.

If you are in the business of building business applications and your software does not run on the web, you are already two steps behind. If you are in the business of building or hosting web sites, applications, or services, get ready to change your conceptual and business models. It might not be fully realized this year, but it is coming.

Categories: watch this Tags:

Building table based forms in Zend_Form

March 24, 2008 11 comments

In web applications it is fairly common to want to edit multiple rows of the same kind of information, formatted into a table, kind of like you can in a spreadsheet. These forms are generally for editing existing information pulled from a database, which is usually already in an array format. Most of the examples I can think of at the moment need explanations of the context to make much sense, so I’ll pick an example that isn’t as likely to be useful but doesn’t need explanation.

Suppose I have a table in my database that lists contacts with title, first name, last name, and so on. When I fetch the data from the database, I’m likely to have an array that looks something like this:

$array[0]['id']    = 1005;
$array[0]['title'] = 'Mr.';
$array[0]['first'] = 'Ted';
$array[0]['last']  = 'Smith';
$array[1]['id']    = 1006;
$array[1]['title'] = 'Mr.';
$array[1]['first'] = 'Mark';
$array[1]['last']  = 'Jones';
$array[2]['id']    = 1007;
$array[2]['title'] = 'Ms.';
$array[2]['first'] = 'Sally';
$array[2]['last']  = 'Adams';

I want to get this into a form structured as a table, that submits the whole thing as one form. So that the posted results like this:

$contacts[1005]['title'] = 'Mr.';
$contacts[1005]['first'] = 'Ted';
$contacts[1005]['last'] = 'Smith';

I want the array to look like this because its much easier to handle the results than if we used the actual field name or id as the variable name.

I couldn’t find anything in the Zend Framework documentation, lists, or various tutorials that explained how to do this very clearly, so I thought I’d post at least one way to accomplish this in Zend Framework. This is based on 1.5. I’m going to start by showing the whole thing together. In practice it might not appear this way in the context of your controller class, but hopefully this is clear enough to understand how to apply it. After I show the whole thing I’ll walk through it and explain the pieces.

$form = new Zend_Form();
$form->setMethod('post')
     ->setAttrib('id', 'contactForm');
$subForm = new Zend_Form_SubForm();

foreach($array as $rownum => $row){
  $id = $row['id'];
  $rowForm = new Zend_Form_SubForm();
  foreach($row as $key => $value){
    if($key == 'id') continue;
    $rowForm->addElement(
      'text',
      $key,
      array(
        'value' => $value,
      )
    );
  }
  $rowForm->setElementDecorators(array(
    'ViewHelper',
    'Errors',
    array('HtmlTag', array('tag' => 'td')),
  ));
  $subForm->addSubForm($rowForm, $id);
}

$subForm->setSubFormDecorators(array(
  'FormElements',
  array('HtmlTag', array('tag'=>'tr')),
));

$form->addSubForm($subForm, 'contacts');

$form->setSubFormDecorators(array(
  'FormElements',
  array('HtmlTag', array('tag' => 'tbody')),
));

$form->setDecorators(array(
    'FormElements',
    array('HtmlTag', array('tag' => 'table')),
    'Form'
));

$form->addElement(
  'submit', 'submit', array('label' => 'Submit'));

$form->submit->setDecorators(array(
    array(
        'decorator' => 'ViewHelper',
        'options' => array('helper' => 'formSubmit')),
    array(
        'decorator' => array('td' => 'HtmlTag'),
        'options' => array('tag' => 'td', 'colspan' => 4)
        ),
    array(
        'decorator' => array('tr' => 'HtmlTag'),
        'options' => array('tag' => 'tr')),
));

As you can see, this approach uses subforms, which allows us to automatically build the array in the form, as well as having a convenient structure for applying decorators. In order to get the array right, we use two layers of subforms (subForm for $contacts, and rowForm to create each row of the table). I couldn’t figure out a good way to not do that and still get the array I wanted in the html. setElementsBelongTo doesn’t quite do the trick.

$form = new Zend_Form();
$form->setMethod('post')
     ->setAttrib('id', 'contactForm');
$subForm = new Zend_Form_SubForm();

This just sets up the form, tells the form it should post and have an id of ‘contactForm’. You might note that I didn’t set an action for the form. Zend_Form does set the action, but leaves the value blank. This conveniently posts the form back to our action (supposing all the browsers handle blank actions as specified in the relevant RFCs). The $subForm line just creates our first subForm for use later.

foreach($array as $rownum => $row){
  $id = $row['id'];
  $rowForm = new Zend_Form_SubForm();
  foreach($row as $key => $value){
    if($key == 'id') continue;
    $rowForm->addElement(
      'text',
      $key,
      array(
        'value' => $value,
      )
    );
  }
  $rowForm->setElementDecorators(array(
    'ViewHelper',
    'Errors',
    array('HtmlTag', array('tag' => 'td')),
  ));
  $subForm->addSubForm($rowForm, $id);
}

For each row in our data we create a subForm, which we populate with an element for each field in our data, setting the value for each to the value from our data. We decorate this subForm in the loop, wrapping each element in a td tag. Note that we don’t need to worry about the name of the element. We just set it to our data field name, and the framework’s subForm handling deals with the rest. Of course in practice your fields might not all be simple text fields, so the actual code would get more complicated but the process is the same. I also should mention that in practice you almost certainly want to check that $array is actually an array before you do this, or you’ll be looking at lots of warnings (at least) in your logs.

$subForm->setSubFormDecorators(array(
  'FormElements',
  array('HtmlTag', array('tag'=>'tr')),
));

$form->addSubForm($subForm, 'contacts');

$form->setSubFormDecorators(array(
  'FormElements',
  array('HtmlTag', array('tag' => 'tbody')),
));

Now that we have a rowForm for each data row added to our subForm, we can decorate each of these with a tr tag, and assign the whole thing back to the parent form. This is where we tell Zend_Form that the parent should be ‘contacts’, so that gets in our result array. Then we decorate the contacts subForm with the tbody tag to get it nicely fit into the table.

$form->setDecorators(array(
    'FormElements',
    array('HtmlTag', array('tag' => 'table')),
    'Form'
));

We need to decorate the whole form with a table tag. This likely needs a class and id, but we leave it plain in this example.

$form->addElement(
  'submit', 'submit', array('label' => 'Submit'));

$form->submit->setDecorators(array(
    array(
        'decorator' => 'ViewHelper',
        'options' => array('helper' => 'formSubmit')),
    array(
        'decorator' => array('td' => 'HtmlTag'),
        'options' => array('tag' => 'td', 'colspan' => 4)
        ),
    array(
        'decorator' => array('tr' => 'HtmlTag'),
        'options' => array('tag' => 'tr')),
));

Chances are we want a submit button, so here we add it to the bottom, and decorate it with its own row in the table.

The order of a surprising amount of this is arbitrary. You could set the table tag toward the top, for example, if it flows better for you. There are, of course, also completely different ways to do this. Several of the examples in the manual extend Zend_Form rather than do it the way that I have here. To me, this seems more clear.

[2010-02-06 I edited this slightly to fix some formatting issues introduced by a WordPress migration.  After almost two years this post still gets visits, and I figured maybe it should be readable.]

Categories: PHP Tags: