Wednesday, July 10, 2013

Why using CouchApps?

Seeing one of CouchDB's coolest features, CouchApps, being neglected by most CouchDB users often saddens me. While CouchDB itself makes for a great noSQL data storage it may also be used to serve web applications with excellence.

CouchApps are nothing but design documents in a CouchDB. They may only contain stuff like map/reduce functions or replication instructions. Yet they may also hold any number of assets like css files, images, videos and so on. On top of that, the document itself is a json document that can be accessed in a common way.

CouchDB's internal http server can then serve those files and data with ease. Data may be displayed and managed by nothing else than the CouchApp itself, eliminating the need for an additional layer all together.

There seems to be a mind problem with that out there in the community. To me it appears almost as if people can't let go of the idea to separate data storage and application. Yes, CouchApps have some limitations to what you can do with them but in most cases those limitations don't get in the way of what the apps are doing.

So by adding another application layer (e.g. a PHP script) all developers really do is to add more work. CouchDB was designed to make life easier. It's ability to serve entire apps is one of the biggest steps in that direction so you should consider making use of it.

To get started, make yourself familiar with Design Documents and all the bits and pieces they may contain. Of course there is a number of tools making life easier.

Even so it's no longer maintained the python tool couchapp still does a fantastic job. Besides the website contains a lot of nice insights into how CouchApps work.

Then there's kanso. Like the couchapp tool it allows you to structure your CouchApp within the file system of your computer. But it does a lot more than just that. Kanso introduces a node.js stype package manager to the world of CouchApps.

Every kanso app is a package and can be reused by another App. That makes it extremely nice to work with in terms of modular design. Imagine a number of apps all of which belong to the same overall project. Another app contains global code and assets like templates, configs, etc. The different apps may then use that "core app" and you can reuse every bit of code in there.

However, each app is completely atomic. You may use different core versions within them so that they can live on their own. Whenever you change something for one app that doesn't necessarily effect all the others. That's good news if you want to avoid adding more problems by solving bugs within one feature.

To me kanso is one of the best choices for webapp development. It's fast and the modular approach makes sharing code a no brainer. I seriously suggest you give it a go and find out how you might save a ton of development time by cutting out the middle man to relax a little more.

No comments :

Post a Comment