I've developed a Restful API in PHP, now the API makes different resources available like: Article, User, Service, Trace etc....
I'm going to implement each resource in a portable DLL, so I can use the API method in each platform as Xamarin, XBox, Windows etc...
I want to ask how I should setup the structure of each DLL.
I'm thinking to use the following stack:

The project name within the solution is the name of the resource, for example Article. Now I have a class called Article. The Article resource implements other sub-resources such as Fam and List. So in the same DLL I can also use the method of other sub-resources. In the solution, for simplicity, I separated each sub resource in their class as:

Article, Fam and List

My RestFull API makes these verbs available: GET - DELETE - POST - PUT. So in my DLL I've created 4 folders with the smen name as the available verbs. In each folder, for example (GET), I have the class resource and sub_resources:

Article_GET, Fam_GET and List_GET

In the classes above I have only the GET method request. In the main class, for example Article I implement all GET - DELETE - POST - PUT classes methods, little example:

public class Article_GET
        public class Article
            public string codice { get; set; }
            public string descrizione { get; set; }

        public class RootObject
            public List<Article> article { get; set; }

        public List<Article> GetArticle()
            var obj = JsonConvert.DeserializeObject<RootObject>("json");
            return obj.article;

and this is the Article class:

public class Article
        public static List<Article_GET.Article> GetArticles()
            return new Article_GET().GetArticle();

so when I import the DLL that has this namespace: CompanyName.Product.Article I can simply use: Article.GetArticles(); or Article.AddArticle() etc...

Image stack example:

enter image description here

I don't know if is this a good stack classes hierarchy. Could someone tell me how I can improve this? Thanks in advance.

  • I'd rather organize my project by endpoint/resource than by method. – CodesInChaos Apr 25 '16 at 13:17
  • @CodesInChaos Each verb folder class have a method that call a resource. Maybe I misunderstood what do you mean? – Dillinger Apr 25 '16 at 13:19
  • A folder per resource and the different methods within that folder. Not the other way round. – CodesInChaos Apr 25 '16 at 13:20
  • @CodesInChaos Aside from that, do you think the overall structure is good? In particular creating a relative to the resource class for a type of verb? – Dillinger Apr 25 '16 at 16:39
  • For starters, read all the guidelines you can find starting here: msdn.microsoft.com/en-us/library/ms229002(v=vs.110).aspx – Andy Apr 26 '16 at 0:03

This looks like it will eventually bite you in the behind, as in that it's very cluttered and doesnt really provide good maintainability.

I would have organized it like this:

Each resource (model) gets its own class file containing its attributes, like:


  • Id
  • Name
  • Price

Each resource collection has a class containing methods for handling that resource, like:


  • Get(int id)
  • List()
  • Update(int id, Article article)
  • Delete(int id)
  • Create(Article article)

Here is a dotnetfiddle example: https://dotnetfiddle.net/YE1hc1

  • In fact it is already so. As you can see from my stack every resource has its own class file Article, Fam and List. Then I organized in folders GET, POST, PUT and DELETE classes containing requests for that verb. I think putting these methods into a single class would really be very bad to handle, as you suggested. – Dillinger Apr 25 '16 at 19:01
  • Well, I can't do more then to warn you, as it seems you will get a lot of duplicated code for nothing. It doesnt make sense out of a REST perspective either, as you've actually implemented state by separating each requst in its own class.. If you decide to keep it this way, which I strongly suggest you dont, you should atleast consider making abstract methods out of the requests and then implement them in each request class. – Simon Aronsson Apr 25 '16 at 20:40
  • Just to better understand what you mean, you could post an example of how your solution should work? Type recalling Article.GetArticles ()? – Dillinger Apr 26 '16 at 6:24
  • 1
    I updated the answer with a dotnetfiddle. – Simon Aronsson Apr 26 '16 at 6:51
  • Ok so you have declared one class Article and put inside of it all the sub-classes for the verbs: GET, POST, PUT, DELETE. What's happean when the request to implement will more of 50s? Should I write all the method inside a single file? For this I've created separate classes for each verbs. – Dillinger Apr 26 '16 at 8:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.