Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I currently have a folder structure on my MVC .NET website that I am completely at a loss as to whether it is acceptable or not. Here is an outline of the structure

[Areas]
   [Area1]
    [Controllers]
    [Services]
      [ControllerName] (relates to name of a controller)
         [Command]
            ... class files here for performing updates,deletes from domain model for each action
         [Query]
            ... class files here for performing getting of viewmodel from domain model for each action
      [ControllerName]
         ...
    [Models]
    [ViewModels]
      [ControllerName]
    [Views]
      [ControllerName]

  [Area2]
     .... (same structure as area 1)

I use the services folder hierachy for performing the code that is responsible for performing mapping of my domain model to my viewmodel and vice versa.

So, the Query folders contain classes that match the Action name it is performing the getViewModel for. e.g. if there is a action in my controller called Index, then I have an partial IndexService class in the Command and query folders.

[Query]
   public partial class IndexService
   {
      public static myViewModel GetViewModel(model objects);
   }

[Command]
   public partial class IndexService
   {
     public void UpdateModel(myViewModel viewModel);
   }

I originally had these in the same class file however the mapping is quite complex at times so the files got quite big with all their related private methods etc. Should these be different class names instead and do away with the folder hierachy? Is this overkill for what I'm trying to do which seperate the different responsibilites get/update out.

Any comments would be appreciated. If you need any more info let me know.

share|improve this question
Why did you split your service into a Command and Query? What does that give you over just having an IndexService with 2 methods? – Trevor Pilley Oct 12 '12 at 22:14
@TrevorPilley I found that at times both methods would share code but also often they would have their own specific private methods. By splitting these up it helped seperate the related methods out and helped keep the code files slightly smaller. – dreza Oct 13 '12 at 3:09

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.