Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 366579
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T13:38:47+00:00 2026-05-12T13:38:47+00:00

i have something like this in my project, the project it’s kinda finished already

  • 0

i have something like this in my project, the project it’s kinda finished already (it’s working)
i just want know if it is ok with the 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 the usage is like this

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

i know that is obvious that it’s violates the SRP, but this class is static and it contains static methods that are independent one from each other, and it’s kind off the same if i would create a static class for each method

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T13:38:47+00:00Added an answer on May 12, 2026 at 1:38 pm

    Far as I can see, there are a lot of SOLID violations right here!

    • Violations of Single Responsibility Principle – First you have data access methods for several classes, second you have helper methods (IsStringNull, IsNull, etc) intertwined with them.
    • Violations of Interface Segragation Principle (as mentioned by Ruben) – If I were only concerned for Products, why do I need exposure to methods that get Users?

    I’m sure there are some others, but these are the glaring ones.

    UPDATE Now that someone commented on it, I think they’re right; the code above looks like it’s some form of extension method abuse.

    For example I don’t believe Data Access should be relegated to extension methods, or worse, a class named “Tools”.

    It’d probably make more sense to have a base class (on a totally different namespace and/or assembly) that abstracts your data access generalities, then inherit one data access class for each unique domain object (e.g., UserDAO, ProductDAO, etc). Do understand that my assumption here is that by GetProduct or GetUser you actually mean GetFromDatabase.

    The rest of the helper methods do belong to extensions so they’re fine.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have something like this: [{'date': 1, 'value':5}, {'date':2,'value':3}, ...] and want to map
I have something like this in my Project#show view: ... <p> <b>Start date:</b> <%=
I am just starting with Servlets/JSP/JSTL and I have something like this: <html> <body>
I have something like this: C:\Users\%USER%\Desktop\MyProject (includes a solution file) \Sample (includes a project
In our project we have something like this: struct PointI { // methods for
Hello I want to do something like this in my project project/ --sources/ --
I have just finished writing the core section of a project I am working
I have something like this in Site.Master in an asp.net mvc3 (not razor) project:
I have something like this in my project: add_custom_command(OUTPUT somefile) add_custom_target(tgt ALL DEPENDS somefile)
In my JSF project, i have something like this <h:outputText value=#{msg[foo]} /> where msg

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.