An Obsession with Everything Else

http://www.derrickschneider.com/atom.xml

Sunday, November 06, 2005

Making a Social Networking Application, Part 3 - Making Objects

Before I dove into the code for my Farmers Market Outings application (see Part 1 for an intro), I jotted down some ideas about the system. There are all sorts of tools and paradigms for this kind of work, but my favorite tool is still a sketchpad (or whiteboard). You can draw quickly and add freeform annotations.

I define objects and relationships simultaneously. If you're not a computer person, an object is just a representation of a complex concept, and a relationship defines how the objects interact. This thing contains that thing. That thing is like this other thing but slightly different. If you are a computer person, I'm of course defining classes, not objects, but that's somewhat more abstract for my non-computer readers.

One of the interesting things about Ning is that you don't have to predefine your objects. Usually, you have to make some assertion about the structure of an object. Here are the attributes, here are the instructions you can give to the object, and so forth. Not with Ning. Aside from certain attributes Ning creates for every object, you can define whatever you want on the fly. And, for the computer folks, here's the neat part: Different instances of a class can have different fields. So City A could have a zip code while City B doesn't. It's a bad idea to actually do this, since then you can't predict what will be in an object, but it still seems like a neat feature.

When you're done stuffing your object, you just push it into the Content Store, a freeform soup that reminds me of the data storage commands on Apple's Newton. You reload it with a system-wide ID or via a query to return a set of objects.

The most obvious object in my application is a Market. Any given market has some attributes. There's a geographical component (the Berkeley Farmer's Market is on Center Street at Martin Luther King in Berkeley, California). There's a time component (the market is open year-round on Saturdays from 10:00am to 2:00pm). Maybe the market has a website. Maybe there's a picture of it somewhere.

But a Market also has relationships to other objects. There are people who shop at the market. There are the vendors who sell at the market. There are announcements ("Market closed this weekend because of Easter"). And in my application, there are "meet-ups" associated with the market.

A Meetup is another kind of object (given my slant as a programmer, everything is an object, but these are the main ones). It has a date, a time, and a meeting place. It can be a private Meetup (you want to talk about your boyfriend as you shop with a friend, but you don't want the stress of meeting new people). A Meetup also has a relationship with the people who use the system: They're the ones who will be meeting.

My notes are more complicated than this description. For instance, a market's country is actually an object (Country) which contains some Regions, which in turn contain some Cities. A market's hours (Monday from 4:00pm to 6:00pm) is another kind of object, and a Market might contain several.

2 Comments:

At 3:42 PM, Anonymous Anonymous said...

I realize that I'm starting to beat a dead horse (or maybe snake), but you can add fields to objects on the fly in python as well. Oversimplifying a bit, classes in Python are basically just dictionaries that you can add stuff to. , and those dictionaries are conveniently called "__dict__" if you want to inspect them. For example:
>>> class A:
... def __init__(self):
... self.dog = 'woof'
...
>>> a = A()
>>> a.dog
'woof'
>>> a.cat = 'meow'
>>> a.cat
'meow'
>>> print a.__dict__
{'dog': 'woof', 'cat': 'meow'}

 
At 8:20 AM, Blogger Derrick said...

Nice. Okay, okay, maybe I'll get around to learning Python soon.

I appreciate the value of this approach, but I still prefer some sort of formal definition about what's in an object. I don't need extra rope to hang myself with; I can usually manage just fine with the rope I'm given.

 

Post a Comment

<< Home