Does this violate SOLID principles?

I have something similar in my project, a project that it has already completed (it works), I just want to know if this is normal with SOLID principles.

static public class Tools
{
    static public GetProduct(this id){...}

    static public GetProductCategory(this id){...}

    static public GetUser(this id){...}

    // I also have here methods like IsStringNull ...
    // IsNull IsFalse, lots of stuff, everything static
}

and use is like this

var UserThatCreatedCategoryForThisProduct = 
      prodId.GetProduct().CategoryId.GetProductCategory().Creator.GetUser();

I know that it is obvious that this violates SRP, but this class is static and contains static methods that are independent of each other, and this is partly the same if I would create a static class for each method

+3
source share
3 answers

As I can see, there are many SOLID violations!

  • . , -, (IsStringNull, IsNull ..), .
  • Segragation Interface ( Ruben). , , ?

, , .

UPDATE , - , , ; .

, , Data Access , , "".

, ( / ), , (, UserDAO, ProductDAO, .). , , GetProduct GetUser GetFromDatabase.

, .

+8

, , ISP SRP , , ( SOLID, ...), .

IMNSHO SOLID ( Agile Principles, Patterns and Practices # Robert C. Martin Micah Martin, , ), .

( - PDF , !), Hanselminutes :

edit: Nabbed the SRP Jon Limjap ppiotrowicz

+2

SOLID .

  • , 3 ( , , ?)
  • ,
0
source

Source: https://habr.com/ru/post/1717902/


All Articles