No meetings with one-day deploy

September 9th, 2011 Alexander Posted in Agile, IT, Programming Comments Off

After attending Kent Becks talk on JavaZone I fell into a discussion with a fellow programmer about Becks claim that on one day deploys you have to get rid of standup meetings (its about 53 minutes in).

The fellow argued that we should get rid of the standup meetings all together, regardless of iteration length. However. I think this is missing the purpose of the daily standup - to get all shareholders in the know.

You need a daily standup meeting if your iteration is a week or longer. The business model might have changed and there is usually a misunderstanding about the requirements or two. Also it's kinda handy to know about the progress on the project for all people involved. These are just some of the things that crop up under a daily standup.

However, when going to daily deploy, or even hourly deploy we just created ourselves a new information channel. The product itself.

We get instant feedback about the features that were implemented by all the users of the product. Either coming in over the phone, email or by tracking statistics.

So yeah, there is a solution for all the programmers that are grudging the daily standup, or all those other meetings: daily deploys.

AddThis Social Bookmark Button

Hva jeg lærte på Startup Weekend

January 31st, 2011 Alexander Posted in Agile, IT, Programming, Social Media, Web development Comments Off

Jeg var på Startup Weekend Oslo i helga. Startup Weekend er en internasjonal happening - en helg for entrepenørskap og nettverksbygging.

Kort fortalt fungerer det ved at flere av deltakerne har en idé til et produkt som de pitcher til massene. I første runde stemmer resten av deltakerne på hvilken pitch de synes høres mest spennende ut. Runde 2 krever litt mer commitment - da velger du ut hvilket team du ønsker å melde deg med det målet å utvikle et produkt i løpet av ei helg. Dette genererer flere team med personer fra ulike bakgrunner - programmerer, økonomer, markedsfolk osv.

Pitchen

Jeg hadde selv pitchet en idé - "Lag din egen avis". En idé som fikk god mottakelse, og et team begynte å samle seg rundt meg.

Resultatet av flere runder med utskifting av folk, tvil og håp og omorganisering av idéen hadde vi på lørdag formiddag spisset den til å bli "Lag din egen avis direkte sendt til din Kindle hver dag".

Arbeidet

@eivindsc begynte på et design. Jeg begynte så smått å programmere på løsningen for å se om det ville fungere teknisk, og @waionline, som vår medieviter, begynte å famle etter et godt navn. NewzUp var født. Og vi gikk live med en webside ca kl 19.00 på lørdag - 24t etter at idéen var pitchet. Websiden inneholdt kun en flott forside som skulle fungere som en tunnell til signup til vår epostliste fram til vi hadde en beta av løsningen klar. Takk til Kristian C. Berge for valg av en effektiv tekst på signup formen.

Vi begynte så å undersøke hvordan vi kunne få interesse for vårt produkt. Vi forsøkte å spre ordet via Twitter, Facebook, venner og forum.

Vår erfaring er at vi ikke fikk den responsen vi hadde forventet via sosiale medier som twitter og facebook. Forklaringen her tror jeg er at disse mediene ikke nødvendigvis fungerer så godt som reklame, men mer som en dialog i etterkant av en lansering. Et medium for å diskutere produktet i bruk - ikke for å spamme. Det er nok brukerne av disse mediene blitt alt for vant til.

Vår største gruppe av interessenter kom fra forum som hadde Kindle som topic. Og her var interessen ganske stor - med en ganske stor signup til vårt nyhetsbrev - 30% conversion rate. Og det uten å ha et produkt ferdig.

Konklusjon

Så min konklusjon er at man kjapt kan sjekke om man har en god idé til et produkt med ganske minimal investering. Design en flott forside med en signup til en lukket beta. Bruk så litt tid til å lete etter forum for å lage posts der som kan generere trafikk. Pluss twitter og en facebook page, for å supplere og at folk lettere kan gi deg tilbakemelding.

Får du en god conversion rate så er det større sjanse for at noen faktisk er interessert i produktet ditt - før du begynner å investere mye tid og penger i utviklere.

AddThis Social Bookmark Button

Debugging Django apps with Eclipse

August 30th, 2010 Alexander Posted in Agile, IT, Programming Comments Off

Yes you can use Eclipse/PyDev as a graphical debugging tool with Python. The trick is to set up your Python environment correctly within Eclipse. When that is done you can harness the power of setting breakpoints and drawing out information of the debugger by stepping through your code.

The path

I use virtualenv when running my Django projects. This way I can set up different Django projects on my development machine and not have them clash when they have different dependencies. I.e. for reise.no I  set up virtualenv like this:

virtualenv /Users/alex/workspace/reise_noENV/

On the command line I go into this virtual environment by issuing

source /Users/alex/workspace/reise_noENV/bin/activate

In Eclipse you'll also need to set up python path to point to this environment.

python-interpreter

After setting up your python environment we can head on over to running tests in debug mode.

Creating a debug runner

Okay, running tests in commandline mode is as easy as doing "python manage.py test". So taking that into regard we'll create a debug runner for Eclipse that does this.

Choose "Run->Debug Configurations" and we'll set up a PyDev Django runner:

pydev-debug-runner

From this screenshot you'll see that we have created a PyDev Django configuration. I'll name it "reise_no test views". Now you can click the "Arguments" tab and fill in "Program arguments" with what you on the command line would enter after "python manage.py". So here we'll enter "test".

Running

You can now run this configuration either via the Debug button you can find on your right in the current dialog. Or you'll find it under the bug icon. Click the small arrow next to the bug and a dropdown list with all your debug configurations should appear.

So add a couple of breakpoints in your code by right-clicking in the margin of the line where you want to break, and run your test via the debug runner. When you hit a breakpoint Eclipse should now go into Debug View.

Debug view

debug-controls

In the Debug View you can now step through your code with the debugger controls. The two controls you'll use the most are

  • Step into (F5): Go one level deeper to see whats going on in there.
  • Step over (F6): Go to the next line.

You'll also have a list of the current variables that are set. Use these to figure out whats wrong with your code.

debug-vars

Okay, thats it. Now get rid of all those print statements you've been so shamefully using and start using the tools at your disposal :)

AddThis Social Bookmark Button

Creating unique IDs with NoSQL

May 12th, 2010 Alexander Posted in Programming Comments Off

I wanted to have unique user friendly IDs for an application I'm working on. No long, hard to type in customer reference numbers. And using MongoDB I didn't have that nifty autoincrementing sql.

The way I solved it was using MongoDBs update command. That command takes an atomic modifier $inc. So you'll need to create a c collection with one document, and increase a value on that counter. Then I'll base64 encode the value to have a slightly more user friendly value. Especially when the sequence grows in size. This is all using Python.

Creating my document:

db.counter.insert({'count': 0})

And here's my unique id generator:

def unique_id():
    db = get_database()
    val = db.command('findandmodify', 'counter', update={'$inc': {'count':1}})['value']['count']
    b = base64.b64encode(str(val))
    result = b.replace('=', '')
    return result

You'll now end up with IDs looking like this:

MA
MQ
Mg
...
MTAwMA
MTAwMQ
MTAwMg
MTAwMw
AddThis Social Bookmark Button

Python value objects

May 11th, 2010 Alexander Posted in Programming Comments Off

When your Python class is essentially a bag of values creating a class for them is a lot of writing - because what you essentially want is to automatically store these values with as little fuzz as possible. So instead you can use the Python 2.6 collections.namedtuple trick.

So instead of doing it one of the old ways:

class Foo:
    bar = None
    gazonk = None

    def __init__(self, **kwargs):
        for k, v in kwargs.items():
            setattr(self, k, v)

You can now do it like this:

from collections import namedtuple
Foo = namedtuple('Room', 'bar gazonk')

You can now init your Foo class with either *args or **kwargs.

AddThis Social Bookmark Button

Testing Django apps with MongoDB

April 14th, 2010 Alexander Posted in Agile, Programming, Web development 1 Comment »

I've fallen in love with #NoSQL. So I'm doing my storage with MongoDB for an application I'm working on. But since I'm also a testing zealot I had to figure out how to test my app properly, with fixtures and all.

There's already some good code out there that will help you develop your Django app using MongoDB - namely MongoKit and django-mongokit.

MongoKit is a great way to make a structure for your document. Complete with validation and all. And by combining it with django-mongokit you also get automatic test database create/drop.

models.py:

from django_mongokit.document import DjangoDocument
from django_mongokit import connection

class Country(DjangoDocument):
    structure = {
        'iso3': unicode,
        'iso2': unicode,
        'name': unicode,
    }

    required_fields = ['iso3', 'iso2', 'name']
    use_dot_notation = True

connection.register([Country])

tests.py

from django_mongokit import get_database 

from django.test import TestCase
from models import *
class ModelsTest(TestCase):
db = get_database()
def test_should_save_country(self): country = self.db.countries.Country() country.iso2 = u'GB' country.iso3 = u'GBR' country.name = u'UNITED KINGDOM' country.save() self.assertTrue(self.db.countries.find())

But the fun doesn't stop there. You can also easily add some fixtures by creating a python file to hold some dicts for you:

countries.py:

countries = [
{"iso2" : "AF", "iso3" : "AFG", "name" : "AFGHANISTAN" },
{"iso2" : "AL", "iso3" : "ALB", "name" : "ALBANIA" },
]
And add this to tests.py:
from countries import countries

class ModelsTest(TestCase):
    def setUp(self):
        db = get_database()
        db.countries.insert(countries)

    def tearDown(self):
        db = get_database()
        db.drop_collection('countries')
Your countries collection will now be populated every time TestCase is created, and dropped when the tests are done running.
AddThis Social Bookmark Button

Aspects with Spring and Maven for getting rid of singletons

January 24th, 2009 Alexander Posted in Programming 1 Comment »

We wanted to update some old hibernate DAOs we had laying around which were implemented using singletons.  Instead of using singletons we wanted to wire these up using the Spring context. This was seemed to be an easy refactoring task. However, diving into the code we came to realize that we had several taglibs developed (extending from SimpleTagSupport) that was using these DAOs. And since you can't have constructors for these tags to dependency inject our DAOs we had to look elsewhere.

Read the rest of this entry »

AddThis Social Bookmark Button

Breaking into the Spring container with singletons

January 15th, 2008 Alexander Posted in Programming 1 Comment »

I was faced with a pesky security library at work. I had written my application with the help of Spring, but the security library was tightly coupled - and I really had viable option of rewriting it as it would break a lot of other applications depending on it. The only bit I could implement myself was the login module - which had to implement an interface with no constructor arguments. So I had to go out and figure out how to break into my Spring container from this login implementation and get a hold of some Hibernate DAOs to do the actual login procedure.

Read the rest of this entry »

AddThis Social Bookmark Button

Maven, Tomcat and Eclipse

January 15th, 2008 Alexander Posted in Programming 10 Comments »

Setting up a productive environment for your web programming experience is going to be a real timesaver once you get it set up correctly. And with Eclipse you can have that Tomcat container of yours up and running with automatic deployment of beans and jsp pages in a snap. Add Maven dependency management into the mix and you have yourself a good coctail to take your mind off those tedious deploy sequences, and instead concentrate on what you love most - hacking the code.

Read the rest of this entry »

AddThis Social Bookmark Button

Creating a folder symlink

February 18th, 2007 Alexander Posted in Programming Comments Off

I've been fiddling about with Applescript recently. And since I have a problem with using iTunes (due to its lack of ogg and flac support), I thought about writing a script which would create a symbolic link to any new artists/albums I added to my music collection.

This would leave me with a list of the newest additions to my music collection as a list of folders in Music:New, for easy playing with Cog.

I wrote the script, but still haven't really gotten past the issue of my need to have a folder action to be recursive. So because I have a "Music:Artist:Album:" structure only new artists are added to my New folder. The only solution I have found is to add this script as a folder action to every Artist folder I got...

Anyways. To use it: ctrl+mouse a folder, select "Attach folder action" and use this script as that folder action. You probably want to edit the paths a bit as well before using it. Its not really production ready.

on adding folder items to this_folder after receiving these_items
tell application "Finder"
if not (exists folder "New" of folder "Music" of folder "kiowa" of folder "Users" of startup disk) then
make new folder at folder "Music" of folder "kiowa" of folder "Users" of startup disk with properties {name:"New"}
end if
repeat with i from 1 to number of items in these_items
try
set this_item to item i of these_items
set the dest to folder "New" of folder "Music" of folder "kiowa" of folder "Users" of startup disk if the container of this_item as alias is this_folder as alias then
make new alias file to this_item at dest
else
display dialog the "container is not root"
end if
on error error_message number error_number
display dialog the error_message
end try end repeat end tell
end adding folder items to

AddThis Social Bookmark Button