couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Campbell <rrc...@gmail.com>
Subject doctype vs. duck typing
Date Thu, 12 Nov 2009 21:40:13 GMT
I'm reading CouchDB in Action and they make use of a doctype in their
examples. This doctype attribute is used in your Map functions to
easily filter out the specific types you want. Example:

if (doc.doctype == "User") // we have a user...

CouchDB: A Definitive Guide, on the other hand, makes use of duck
typing. Essentially you determine that a document is a duck if it
quacks and flies:

if (doc.quacks && doc.flies) // Looks like a duck..

What are the pros and cons of each approach? Which one do you guys use and why?

Mime
View raw message