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 6363497
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:02:45+00:00 2026-05-25T00:02:45+00:00

I’m currently in the process of working in a class design for a web

  • 0

I’m currently in the process of working in a class design for a web application I’m building. I’m relatively new to OOP (although I have done some). For the most part I’m fairly confident that I know what I’m doing in the paradigm: I know that it’s not good practice for one class to access the internal workings of another class, that unsafe static methods are unsafe because they can modify global state, and that generally speaking, the more purely functional and modular I can keep my code the better off I will be.

I’m a little unsure of what to do in this situation though. I have multiple web pages which all have their own GridView control. Some logic will go through each row and change the color of the row based on certain conditions. Would it be considered bad practice, for example, to keep one static class encapsulating these style changes, which will be accessed by every page? Technically this means that this class would be modifying a member of another class. How should I go about this? I would prefer not to duplicate my code through each class, as I try to adhere to the DRY principle as much as possible.

EDIT: Here’s what I’m thinking.

public static class RowStyle
{
    public static void SetRed(GridViewRow row)
    {
        row.BackColor = Color.Red;
    }

    // More methods here
}

And each page will pass many GridViewRows to this class, and then have them modified.

  • 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-25T00:02:46+00:00Added an answer on May 25, 2026 at 12:02 am

    Generally, static methods are not so much of a problem if they dont modify static state. Therefore, as long as everything it needs is either encapsulated in the method, or passed in via params then there is less of an issue.

    Eg, following your example, the following would IMO be fine

    public static class Colorizer
    {
        public static void Colorize(GridView gv)
        {
          // do you're funky logic here.
        }
    }
    

    And use that method in each of your pages that need the logic.

    However, this would be bad bad bad:

    public static class Colorizer
    {
        private static bool haveIAlreadyColorized = false;
        public static void Colorize(GridView gv)
        {
           if(!haveIAlreadyColorized)
                // do you're funky logic here.
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
Seemingly simple, but I cannot find anything relevant on the web. What is the
I have this code to decode numeric html entities to the UTF8 equivalent character.

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.