0

I am building a winforms screen. On the screen, it will show

Category1
  Sub-1-1
  Sub-1-2
  Sub-1-3
Category2
  Sub-2-1

Click on the sub-1-1 will popup an screen and show the data related to sub-1-1; same for sub-1-2, ... etc. So there will be totally five forms (1 main form + 4 popup forms for the sample above (the actually will have about 30 sub categories)).

I have models for Categories, sub-1-1, sub-1-2, ..., sub-2-1. I am writing a service layer. Should I do,

public class ServiceLayer 
{
  CategoriesModel GetCategories();
  Sub11Model GetSub11();
  Sub12Model GetSub12();
  Sub13Model GetSub13();
  Sub21Model GetSub21();
  .....
}

Or each form has its now service class instance?

public class ICategoryService { ... }
public class ISubCategoryService<T> 
{
  T GetSub();
}

var sub11 = new SubService<Sub11Model>();
var sub12 = new SubService<Sub12Model>();
var sub13 = new SubService<Sub13Model>();
var sub21 = new SubService<Sub21Model>();
....
ca9163d9
  • 27,283
  • 64
  • 210
  • 413

1 Answers1

1

The first one looks like a GOD class and will probably violate most of the SOLID principles. It will make the code hard to refactor, even if it's just a facade.

You should of course use smaller interfaces which is only handling one responsibility.

jgauffin
  • 99,844
  • 45
  • 235
  • 372