About Twitter Object-Oriented Design
More than 2 years ago I sort of reversed-engineered and created a Facebook Object-Oriented Diagram which demonstrates relationships of objects and entities used by Facebook. To my surprise this diagram was later used as example by many Facebook development related groups and linked to in blogs.
Today Twitter is a new kid on the block and now I'd like to talk a little bit about Twitter design in terms of object-oriented approach.
In one sentence: twitter design is very simple but not straightforward - a bit unconventional.
In general Twitter has only 2 objects: Status and User. Where Status has a field of User type and User has a field of Status type (it is usually used to indicate the latest user status). One can ask what is the difference between User and [Status].user? Or what is the difference between Status and [User].status? Don't you feel we are going somewhat out of boundaries here?
OK, the main difference is that [Status].user.status is null while [User].status is not null (or [User].status.user is null and [Status].user is not null) and this is the limitation of the Twitter API.
Here comes the weird thing. Let's suppose we have [Status] as input and need to get fully populated [User] as output. The code can go like so:
public User GetUser(Status stts) { User usr = null; if (stts != null) { stts.user.status = stts; usr = stts.user; } return usr; }
Enjoy :)
Saturday, July 4, 2009 7:05 PM