Hey guys -

So I was just starting to add a messaging service to the java code and I saw
that the new java service interfaces still need a lot of cleanup. I also
noticed how similar they were to one another because of how structured the
rest calls have been making everything. So... I started thinking about a
generics based interface that could work for all of the different types of
objects we currently have and could hopefully extend to photos, movies, etc.


Anybody want to give me some quick feedback on a simple service like this:

// T is the type of model object that this service deals with. (I know,
crappy name, feel free to suggest a better one)
// T = Activity, Person, Message or Map<String, String> (ie Data)

public interface ItemService<T> {

  public ResponseItem<RestfulCollection<T>> getItems(UserId userId,
      GroupId groupId, String appId, Set<String> fields, SortOrder sort,
      SortDirection direction, FilterType filter,
      int first, int max, SecurityToken token);

  public ResponseItem<T> getItem(UserId userId, GroupId groupId, String
appId,
      Set<String> fields, String itemId, SecurityToken token);

  public ResponseItem<T> deleteItem(UserId userId, GroupId groupId, String
appId,
      String itemId, SecurityToken token);

  public ResponseItem createItem(UserId personId, GroupId groupId, String
appId,
      Set<String> fields, T item, SecurityToken token);

  // None of the services have this right now... but it maps to "put" in
rest. Will we ever actually use this call?
  public ResponseItem updateItem(UserId personId, GroupId groupId, String
appId,
      Set<String> fields, T item, SecurityToken token);

}

Now Data doesn't -quite- fit with this model because it doesn't return a
List<T> it should return a Map<String, T> but yeah.. we can special case
that somehow for now or eventually be more standard and get rid of it. We
could also compose userId, groupId and appId into an object to remove some
of this overly large param list clutter or something...


Alright, so, "horrible idea I've lost my mind" or "so, so idea I don't think
it'll work long term" or "sure, go and refactor it".
Thanks.

- Cassie

Reply via email to