Take the 2-minute tour ×
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

closed as off-topic by Mat's Mug, syb0rg, Jamal Feb 13 at 4:57

If this question can be reworded to fit the rules in the help center, please edit the 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
1  
@TrevorPilley: This seems to be following the Command-Query-Separation pattern (also sometimes called CQRS - Command-Query-Responsibility-Segregation) –  ChrisWue Dec 3 '13 at 10:16
    
@ChrisWue Yes, that was what I was trying to get at at the time as I think I remember I read about it and thought it a good idea –  dreza Dec 3 '13 at 19:23
2  
This question appears to be off-topic because it is about high-level architecture. This question might have an answer on Programmers.SE. –  Mat's Mug Feb 13 at 4:52

Browse other questions tagged or ask your own question.