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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:34:04+00:00 2026-05-25T15:34:04+00:00

It is likely that I am going about this all wrong, but I have

  • 0

It is likely that I am going about this all wrong, but I have a user control called CategoryControl, there can be many like it, for that reason I decided that many of its functions would be better served as static methods. I wanted to know if there is a “better” way of accessing these methods then passing an instance all over the class. The methods are public static as they will be updated by other methods. The though of making extension methods comes to mind..?

public CategoryControl(UserCategory userCategory)
{
   InitializeComponent();

   PopulateControl(userCategory, this);
}

private static void PopulateControl(UserCategory userCategory, CategoryControl instance)
{

   SetCategoryTitle(userCategory, instance);

   SetPercentCorrect(userCategory, instance);

   SetQuestionsMissed(userCategory, instance);

   SetBackgroundBar(userCategory, instance);

   SetForegroundBar(userCategory, instance);

}

Updated::

The longer story is that I have a Panel on the screen, the panel contains relevant user categories. By relevant I mean that the user has the option of changing courses thus displaying a new set of categories. A user can also change the values of a category based on their interaction with the software. So…

A panel shows the categories of a course.

I maintain a list of the active Category Controls in the panel, and the main form tells the panel when to draw a new set of categories.

public void InitializeProgressPanel(UserCategories parentCategories)
{
   Contract.Requires(parentCategories != null, "parentCategories is null.");

   RemoveAllControlsFromList(_categoryControls);

   UserCategories sortedUserCategories = parentCategories.SortByWorst();

   int categoriesCount = parentCategories.Count();

   int spacer = (Height - (CategoryControl.Controls_Height * categoriesCount)) / categoriesCount+1;

   for (int i = 0; i < sortedUserCategories.Count; i++)
   {
      CategoryControl cc = new CategoryControl((UserCategory)sortedUserCategories[i]);

      cc.Left = 0;

      if (i == 0)
         cc.Top = spacer;
      else
         cc.Top = (Controls[i - 1].Bottom + spacer);

      Controls.Add(cc);
      _categoryControls.Add(cc);

      }
}
  • 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-25T15:34:05+00:00Added an answer on May 25, 2026 at 3:34 pm

    I would certainly not make extension methods if I had a class in hand that I could extend. Remember, the purpose of extension methods is to extend types that you cannot extend yourself.

    The question at hand then is, should you say:

    class C 
    {
        public void Foo() { ... }
    }
    

    or

    class C
    {
        public static void Foo(C c) { ... }
    }
    

    I would ask some questions like:

    • Is the class ever going to be subclassed? If so, should this be a virtual method?
    • Is Foo the kind of thing that an instance does to itself, or the sort of thing that it has done to it? An animal eats on its own, but an animal is fed by someone else.

    UPDATE:

    Some more questions I’d ask myself:

    • Are the properties and whatnot you are setting ever going to change? The less mutability you have in a class, the easier it is to test, the easier it is to reason about, and the fewer bugs you’ll have. If the properties and whatnot are never going to change then do not set them in any kind of method. Set them in the constructor and then never worry about them again; they’re correct.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm most likely going about this the wrong way, but I was wondering if
Very likely I'm going about this in the wrong way entirely. I'm completely new
I might be going about this all wrong, so hopefully someone will tell me
This can be in any high-level language that is likely to be available on
I'm starting a web project that likely should be fine with SQLite. I have
I realize that the answer to this question is likely quite obvious (if somewhat
I'm fairly new to C++, and I'm likely in over my head, but that's
This likely applies to non MVC too. But, Is it possible to use the
This is likely going to be an easy answer and I'm just missing something,
There is a similar question going around, but it just got the same old

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.