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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:30:36+00:00 2026-06-10T01:30:36+00:00

We have a Basewebpage class having many common functions like filling up dropdowns, formating

  • 0

We have a Basewebpage class having many common functions like filling up dropdowns, formating , return formatted datatable and so on..

What would be a good approach.

Public Class BaseWebPage
{
 ...

    public static DataTable Static_GetPersonDataTable()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Name");
        dt.Columns.Add("Age");

        return dt;
    }
  ...
    public DataTable NonStatic_GetPersonDataTable()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("Name");
        dt.Columns.Add("Age");

        return dt;
    }
}

This is how both can be called

DataTable dt1 = BaseWebPage.Static_GetPersonDataTable();  // calling static method
...
BaseWebPage pageBase = new BaseWebPage();
DataTable dt2 = pageBase.NonStatic_GetPersonDataTable();  // calling non-static method

Few questions in above scenario

  • Will both method return new instance of a datatable or static will always return the same?
  • During heavy load (Many requests) case will there be any thread related issue for any of these?
  • If there are no side effects which is preferable over other? Why?

if you can write little bit descriptive it will be really helpful.

  • 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-06-10T01:30:38+00:00Added an answer on June 10, 2026 at 1:30 am

    •Will both method return new instance of a datatable or static will always return the same?

    Yes they will return a new instance.

    •During heavy load (Many requests) case will there be any thread related issue for any of these?

    No unless you use shared state in your methods. Currently they don’t but they may. Even the instance methods may use shared state. This is not related to staticness (staticity?)

    •If there are no side effects which is preferable over other? Why?

    It doesn’t really matter but I would go for instance methods. At some point you may want to add tests and you can extract the methods in an interface and mock the object.

    Bonus point:
    DataTables suck! Avoid them and use classes/objects.

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

Sidebar

Related Questions

have written this little class, which generates a UUID every time an object of
Have a procedure which looks like Procedure TestProc(TVar1, TVar2 : variant); Begin TVar1 :=
have some headers like: HTTP/1.1 100 Continue HTTP/1.1 302 Found HTTP/1.1 200 OK HTTP/1.1
have a php code like this,going to convert it in to C#. function isValid($n){
Have advancements in CPU design like dynamic instruction scheduling narrowed the performance gap between
have such kind of error. When adding Redirect 301 rule to .htaccess file like:
have found fragments to be very useful in constructing dynamic html - like using
have any idea for this? example code: <td> <div class=translate> <p><span>Hello world</span></p> <p><strong>hellow <span>there</span></strong</p>
Have found maven to use hard for simple things like jar-signing ..May be I
Have a recurring situation, petty I know, but I'd like to consolidate the following:

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.