Rapid Prototyping

If you’re like me, you enjoy doing lots of quick CRUD (create/read/update/delete) applications that are highly experimental, highly volatile and require low commitment until you know where you want to go with it.

Having worked with various web frameworks (Django, Rails, Sinatra, webpy, Struts, Express, Flask, and probably some other ones I’ve missed), I find that as a coder, one needs a nice balance of getting code up and running on a local machine and not having to organize and plan too much when in “play mode”. By “play mode”, I mean MTAWGSBWATL a.k.a. “Maybe This App Will Go Somewhere But Worry About That Later”.

This kind of mentality is very useful for both beginners and those who are more advanced in their programming career. Think of it as taking a bunch of clay and molding it until you feel that you have the right fit. The last thing the experimental coder needs is to think about is the “ideal organization” of their code and more about getting it running on a local webserver as soon as possible.

I find two frameworks quite efficient at getting this done – Sinatra and Flask. In this post, I’ll be specifically talking about Flask, BrowserID and MongoDB.

Now a quick summary of these three things:

  1. Flask is a lightweight Python framework
  2. BrowserID is a secure authentication service
  3. MongoDB is a nosql database

Why would one use these for an application, especially one that is prototypical? First, because we don’t want to over-engineer our code right now. Second, because we don’t want to write our own or maintain an authentication platform that requires us to either handle anything beyond a user’s session, uses a third-party service (such as Twitter or Facebook) which some people may not feel comfortable in signing in with and we want to get things done as fast as possible. Finally, because there’s no point in planning a relational database with something like MySQL or PostgreSQL when you may not even know what you are designing. You may not even know what you’re doing! So keep it simple and to the point.

For my examples, I started with Lexicrypt. Lexicrypt is a fun, small project that generates encrypted messages as images. It took me about a week to get the first iteration up and running on a publicly accessible server. Your mileage may vary – if you’re experienced in Python, this may take you about the same amount of time or less. If this is your first time, don’t worry about taking longer – you’ll eventually find your comfort zone and your modus operandi for developing personal scaffolds of your projects.

Shortly after I created Lexicrypt, I decided to make a small photo service that enables you to sign in, upload photos, tag and favourite them. Instead of starting from scratch I took the scaffold of Lexicrypt, popped out the encryption functionality and replaced it with the photo functionality. This enabled me to go from idea to deployment for the first iteration within a weekend!

To view the source for these projects and get an idea of their similarities and differences you can check out the Github repositories at https://github.com/ednapiranha/lexicrypt and https://github.com/ednapiranha/snapshots-from-here.

As for your rapid prototyping endeavours, good luck and continue to code and code some more. Remember, the process is not only a way for you to learn how to code more efficiently and collaborate with others as you gain more experience, but it is also a way for you to learn more about yourself in the development of your application.

Here is a video of me giving a lightning talk on the subject:

 

10 responses

  1. Mike Morgan wrote on :

    Awesome! Nice job Jennifer!

  2. Fred Wenzel wrote on :

    Awesome post!

  3. travis wrote on :

    Great article!
    I’m working on a pretty extensive code generator to do exactly what you’re talking about. PHP instead of python but same concept.

  4. Alex wrote on :

    Where do you stage or host your stuff?

  5. Anderson Cardoso wrote on :

    Great post. This stack, is not just my prototyping stack, but my favorite real-world application stack.
    I really enjoy flask + mongodb, and browserID only makes everything better.

  6. M. wrote on :

    Is the content of the video contained in the post, or is there additional material?

    Would you consider adding subtitles?

  7. Bart J wrote on :

    Thank you so much for this.

    I feel like I have a lot of ideas but never get off and start because it would take too long.

  8. Wouter wrote on :

    I’m using Flask with SQLite myself, trying to hack together my own (very) basic authentication module for quick experiments. I never looked into BrowserID, might be worth a shot. Thanks!

  9. Jennifer Fong wrote on :

    Yep, the content in the post is just the summary of the content in the video!

  10. Jennifer Fong wrote on :

    Depending on the framework and resources, I deploy either on Linode using Gunicorn and Nginx or I use Heroku. Lately I keep my Python projects on Linode and Node projects on Heroku.

    For the MongoDB parts, I have been using MongoHQ, since it’s easy to look up data while debugging.