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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:51:38+00:00 2026-06-15T21:51:38+00:00

We do use util functions and some functionalities like Logger,EventWriter,Some Common DB calls,etc often

  • 0

We do use util functions and some functionalities like Logger,EventWriter,Some Common DB calls,etc often in our code. I prefer these functions to be static, because instantiating the functions from these classes in every one of my code would be a serious performance hit(would it be ?!!!? , I’ve read in stackoverflow that too much of class instantiantions would be a performance hit, I’m working on a Project with big Customer Database and high access log on the server). And I have came across static import in java which looks cool, and I want to know: is there any Serious Considerations there before using it?

Things i’ve gathered already from StackOverFlow :

Using static import could make the Code Non-Readable, like judging the
function definition.

Other than that , any Pretty issues which i have to worry about ..?

Old Code :

class myservlet extends httpServlet
{
    pubilc doPost()
    {
        Utils utils = new Utils();
        DBFuncs dbFuncs = new dbFuncs();
        Logger logger = new Logger();
        EventWrtr eventWrtr = new EventWriter();

        utils.GetEscapedName(name);
        logger.Log("error");
        eventWrtr.WriteEvent("something happened");
        // Getting new Objects for every servlet calls

    }
}

My Current Code : ( Hope this will avoid unnecessary Instantiations, the code was like above, i’m changing it now like this)

/* Declaring all the methods in the below classes as static methods */  
import com.mycom.Utils;
import com.mycom.DBFuncs;
import com.mycom.Logger;
import com.mycom.EventWrtr;
class myservlet extends httpServlet
{
    public doPost()
    {
        Utils.GetEscapedName(name);
        Logger.Log("error");
        EventWrtr.WriteEvent("something happened");         
    }
}

I Kinda like this and i want to know any Serious Issues especially performance related in using the below approach

/* Declaring all the methods in the below classes as static methods */  
import static com.mycom.Utils;
import static com.mycom.DBFuncs;
import static com.mycom.Logger;
import static com.mycom.EventWrtr;
class myservlet extends httpServlet
{
    public doPost()
    {
        GetEscapedName(name);
        Log("error");
        WriteEvent("something happened");           
    }
}
  • 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-15T21:51:39+00:00Added an answer on June 15, 2026 at 9:51 pm

    The static import feature is a syntactic sugar kind of feature, so it cannot have performance implications. It does have negative consequences to readability and testability, though:

    • You dump the content of a potentially large class into your current namespace, making your code harder to read; modern IDEs mitigate this by letting you navigate to the definition of the object by clicking its name in a program.
    • Your code relies upon static objects, making it extremely hard to test. For example, you cannot easily drop a mock logger, and expect your code start using it. This is a general limitation of using static objects, though – you get it when you use static objects, with or without the static import.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wrote a wrapper class to abstract some functions of PDFBox I use often.
I created a module named util that provides classes and functions I often use
I am trying to use org.apache.commons.collections.CollectionUtils in android with following code import java.util.ArrayList; import
Can I use java.util.Properties with encoding different then default?
I'm trying to figure out how to use the java.util.logging features. All of the
I use a TextRenderer (com.jogamp.opengl.util.awt.TextRenderer) to draw text to the screen, however after I
I'm getting this error when I use MarshallingView to marshal my list (java.util.List) of
I'm writing a BloomFilter and wanted to use Scala's default MurmurHash3 implementation: scala.util.MurmurHash3. My
We are creating a gadget for the opensocial API 0.7. In some functions we
I have to use some JavaScript and CSS for my portlet. I am using

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.