Designing an Interface - SimpleDB CFC

I'm working on a ColdFusion library for Amazon's SimpleDB, and I'm mulling over the options for how I want the library to work. I've completed the authorization code and the methods that deal with creating, listing, and deleting domains. They exist well as function calls, with the listing method returning a query object for easy iterating.

The two pieces that remain are the methods that deal with items (records within the domain) and queries against a domain. Here are a few options that I have, and I'd love some feedback!

Item Methods

SimpleDB allows you to add attributes to an item and remove them, as well as retrieve all (or a subset) of the attributes of an item.

There are two main approaches here: Present an Item object with methods, or present the methods within the main CFC itself.

Presenting an Item as an object would work like this:

item = simpledb.getItem(domainname, itemname)
item.setAttribute(attributename, attributevalue, replace=false)
item.deleteAttribute(attributename)
foo = item.getAttribute(attributename)
item.persist()

Presenting methods from the main cfc would look like this:

simpledb.setAttribute(domain, item, attribute, value, queue=false)
simpledb.deleteAttribute(domain, item, attribute)
foo = simpledb.getItemAttribute(domain, item, attribute)
mystruct = simpledb.getItemAttributes(domain, item)
simpledb.persistChanges(domain, [item])

In either case, changes could be queued in the system until persist() or persistChanges() was called. This way, multiple attribute sets could be combined together to speed processing.

The examples I provide here are a bit rough, but I'm sure you get the idea.

Which of these options is going to be more simple / coldfusion like?

Queries

The SimpleDB API returns a list of itemnames to queries. This means that to access the data, you need to query the attributes for each item. The simplest option would be to return the list of itemnames, and allow use of the other methods to get the desired attributes.

A more full-featured interface would have the option to get the attributes for each item and form it into a query. An iterator object could be another option, with either attribute access methods or simply returning an item object similar to the one mentioned in the item section.

Plea For Thoughts

So, does this rambling question make any sense? Which style (thin and rough, fat and friendly) of API interface do you prefer?

If my thoughts need to be better formed before any worthwhile answer can be given, please let me know.

Related Blog Entries

Comments (Comment Moderation is enabled. Your comment will not appear until approved.)
Hilton's Gravatar I've never coded in CF, so I can't speak to that aspect. However, in general I would say presenting the item as an object is a cleaner approach. It not only makes sense intuitively (to me at least), but it also reduces the number of arguments in method calls. Given the small size of the library, I think it helps rather than hurts the ease of undesrstanding.
# Posted By Hilton | 2/20/08 10:02 PM
Chris's Gravatar I'd also vote for the object approach. I found this post while searching for a simpledb cfc, I am considering writing one and also doing an interface in AS3 for Flex / Air. It would be great if you could release your work in a way that the CF community could benefit from. Thanks!

Chris
# Posted By Chris | 3/8/08 11:38 PM
Sam Curren's Gravatar I've decided on a two layer approach: One function oriented layer that performs all the functions, and an OO layer that rides on top to provide the convenience. That way, users can use either layer, depending on their requirements.

I've delayed the project a little bit, although I do have working code. There is a bit of fragmentation between the different Amazon Web Services ColdFusion libraries, and before I put the real polish on what I have, I want to create a group of the other authors and see if we can consolidate them all into one library, with somewhat of a uniform interface shared between them.

If you (@Chris) or anyone else would really like a copy of my code now, then holler, and I'll post it somewhere in it's incomplete state so you can not rebuild what I already have.
# Posted By Sam Curren | 3/9/08 3:49 PM
David Smith's Gravatar I have already created a SimpleDB CFC and front-end, and packaged it with my ColdFusion-based AWS Console project on RIAForge. Check it out. I just posted it a few days ago.

http://awsconsole.riaforge.org/

It is also linked from Amazon: http://developer.amazonwebservices.com/connect/ent...
# Posted By David Smith | 3/19/08 12:03 PM
mbt shoes's Gravatar wearing MBT has become a phenomenon! we offer mbt shoes physiological footwear in all styles,mbt.com official online shop,Quality Guarantee. http://www.mbts-mbtshoes.com
# Posted By mbt shoes | 6/5/10 1:58 AM