0

So I have a little bit of a problem. I working on a project in C# using The StackOveflow API. You can send it a request like so:

http://stackoverflow.com/users/rep/126196/2010-01-01/2010-03-13

And get back something like this JSON response:

[{"PostUrl":"1167342",
  "PostTitle":"Are ref and out in C# the same a pointers in C++?",
  "Rep":10},
 {"PostUrl":"1290595",
  "PostTitle":"Where can I find a good tutorial on bubbling?",
  "Rep":10}
 ...

So my problem is that I have some methods like GetJsonResponse() which return the above JSON and SaveTempFile() which saves that JSON response to a temporary file for later use. I not sure if I should create a class for them, or what namespace to put them under. Right now my current namespace hierarchy is like so: StackOverflow.Api.Json. So how should I organize these methods/classes/namespaces?

Nikola Smiljanić
  • 26,745
  • 6
  • 48
  • 60
Bob Dylan
  • 4,393
  • 9
  • 40
  • 58

1 Answers1

2

I would suggest you have a class representing a site, which knows about the URLs involved etc, then a method such as GetReputationChanges(int userId, DateTime from, DateTime to). That can return you a list of posts (where a post is another class).

All of this should be in the same namespace, IMO.

I have some of this already for my Reputation Tracker - I don't know to what extent this has already been built into the API that Kevin has built. You're aware that they're working on an official API though, right?

Jon Skeet
  • 1,421,763
  • 867
  • 9,128
  • 9,194
  • I should really read the blog before I start a new project. I didn't know Kevin was building an API for .NET. Oh, well. – Bob Dylan Mar 13 '10 at 07:27