Archive for September, 2008

OOPSLA 2008

The Object-Oriented Programming, Systems, Languages, and Applications or more commonly referred to OOPSLA, annual conference is right around the corner. Oct 19th through the 23rd in Nashville, TN. I am trying to get my company to pay for me to go, but on such short notice, doubt it will happen, even so, I should be able to get paid time off to attend.

This years conference is looking to be a great one. As always they have a ton of workshops and tutorials and the keynotes this year look decent. I am particularly interested in the “Building Service-Oriented Architectures with Web Services” and “Test-Driven Hands On” tutorials. Those fall in to my line of work and I am always interested in seeing how others approach the same problems.

As for the keynotes Rebecca’s “What Drives Design” and Mark Dominus’ “Atypical Types” both spark my interest.

e is a text editor for Windows based off the popular Mac TextMate editor. I’ve started using it over Eclipse. It isn’t a full on IDE, but with the use of Bundles and the ability to easily script things out in e, I find myself more productive using e vs. Eclipse.

The price tag is $40. Well worth it. Get yourself an integrated source control program like TortoiseSVN, use the open directory as project feature of e and you’ll be off to the races.  The !TextMate bundles and scriptlets out there work in e without modification, another nice bonus. Now, granted you do lose out on ticket integration and some other high level things Eclipse offers as plugins, but overall, I’m preferring e and using it as my primary editor for development now.

Another good thing, given my long term plans as always have been to get myself a Mac, I’ll feel comfortable with !TextMate right away.

In the process of creating a new web service for the purpose of allowing external applications to communicate with my site, I realized I was going against the grain and making things harder for myself than they had to be.

Pylons and Python make it so easy to just start pounding out code you can be half way through an implementation before you realize it is broke, or reinventing something that already exists, or just plain sucks.

So, I do a commit to my local repository, Ctrl+A and hit delete. Lets try this over. I take a step back and look at what we need to do.

We have a Kill object. This is a representation of a Ship a Pilot and another or many other Ship(s) and Pilot(s) who destroyed this ship and where and why the did it. That is the verbose text version of a kill. My remote service wants to perform CRUD operations on this model. I have all this implemented already, the controllers for my views do all of this .. so why not copy them and just give them some tweaks and expose these new methods under a poorly named controller? Great idea! .. Not so much.

So, the solution, create a new REST controller in Pylons. Pylons does all the heavy lifting for you with a simple command, the only thing you need to do is update your routing.py to include the new resource. You create the REST controller just like you would a normal, but using restcontroller instead of controller and adding and extra variable for the name of the resource. Usually a plural of your model.

# paster restcontroller kill kills
Creating wayne\qkb\controllers\kills.py
Creating wayne\qkb\tests\functional\test_kills.py
To create the appropriate RESTful mapping, add a map statement to your
config/routing.py file near the top like this:
map.resource('kill', 'kills')

Ok, so what did that give us? Well, basically everthing we need. If you pop open kills.py in your controllers, you’ll see it already has sketched out the methods  you’ll be implementing for your kills resource and also gives you a reminder to update your routing.py

From here, it is rather simple. Just implement the responses in each of the methods that your external application will need. Don’t forget to change the formats from HTML if you aren’t going to be sending back to a browser or HTML parser. Example of the index implementation. Which would be called using a GET to /kills under the default routing.

def index(self, format='xml'):
    """GET /kills: All items in the collection."""
    # url_for('kills')
    kill_q = meta.Session.query(model.Kill)
    c.kills = kill_q.all()
    return render('/derived/kills/list.xml')

Following this pattern, I implement the rest of my resource methods and end up with a fully functional resource with in minutes. Not only was this faster to live than modifying the methods that were designed for handling posts from the view layer, it also creates a much cleaner exposure of the Kill model to external services. Heres the implementation of create, which is /kills with the POST method.

def create(self):
    """POST /kills: Create a new item."""
    # url_for('kills')
    try:
       params = model.forms.schema.KillSchema.\
                to_python(request.params)
       kill = model.Kill(**params)
       meta.Session.save(kill)
       meta.Session.commit()
       c.killid = kill.id
       return render('/derived/kill/create.xml')
    except formencode.Invalid, e:
       c.errors = e.errors_dict() or {}
       return render('/derived/kill/error.xml')

I recently renewed my ACCU and ACM memberships after letting them go for a couple years. I feel like I’ve done myself a disservice by letting these lapse.

Both of these organizations provided me with countless hours of information and insight as a younger developer and I attribute their journals and usergroups to helping me become the programmer I am today.

These organizations promote growth and learning and both have the goal of making people do what they do better. Easier, smarter, more efficient. I think any programmer who cares about their craft and improving their abilities should seriously look at joining one or both of these organizations.

If you’re a past member who has let their subscription lapse it might be time to look in to renewing it, it will pay for itself many times over.

  • ACM – http://www.acm.org (a Plone site! Yes, seriously)
  • ACCU – http://www.accu.org (member count seems thin, but content is still great)

Both give you nice print subscriptions to their journals and access to their mailing lists and discussions. ACM membership also affords you access to Books24×7 and Safari.

A recipe site to end all recipe sites?
After going through piles of recipe and food sites I found absolutely nothing that met my needs, be it a pay site or a free site. Nothing did what I was looking for. After speaking to some friends and family, throwing around my ideas, I decided that was I was looking for wasn’t all that far fetched, just no one has really taken the time to do it.

First, lets cover what is how there.

  • Recipe sites (tons)
  • Diet sites (tons)
  • Kitchen/pantry inventory sites (a few)

Doing some quick Google searches for those terms and you’ll find yourself piles of links. You’ll find plenty of sites that do food tracking for diets, plenty that do recipes, some that combine diets with recipes, but none that combine all three.

What I want from a site

  • Recipe database
  • Item database (for recipes and shopping lists)
  • Ability to add new recipes
  • Ability to edit existing recipes
  • Kitchen/pantry inventory (barcodes?)
  • Daily, Weekly, Monthly food planning
  • Sensible shopping lists (more on this)

That is a fairly short list and I was unable to find all those elements in any site. As for those sites that had some of the elements, most were over complicated and far from intuitive to use.

Sensible shopping lists
Ok, simple example. Lets say you add the Chips and Salsa recipe to your list of items you’re eating this week. Your pantry inventory doesn’t contain chips or salsa. Most sites that incorporate recipes and shopping lists will give you a shopping list like this

  • 1/2 cup Salsa
  • 10 tortilla chips

OR it will just remove the quantities

  • Salsa
  • Tortilla Chips

The second one isn’t actually that bad, because that is what you need. The problem with the second list is when you already have Salsa or Tortilla chips. Most sites have no tie in to kitchen inventory. This site, if used religiously for all your recipes and meals would provide an accurate shopping list for all meals planned based on the shopping list you choose to receive.

This means you could enter in all your recipes, plan your meals for 3-months, and bring out 1 week or 2 week lists. As you mark meals cooked for each day, the lists will dynamically update to provide accurate inventory tracking.