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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T06:57:10+00:00 2026-05-15T06:57:10+00:00

Does it affect the time in loading the application? or any other issues in

  • 0

Does it affect the time in loading the application?
or any other issues in doing so?

  • 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-15T06:57:11+00:00Added an answer on May 15, 2026 at 6:57 am

    The question is vague on what “long” means. Here are some possible interpretations:

    Interpretation #1: The constructor has many parameters

    Constructors with many parameters can lead to poor readability, and better alternatives exist.

    Here’s a quote from Effective Java 2nd Edition, Item 2: Consider a builder pattern when faced with many constructor parameters:

    Traditionally, programmers have used the telescoping constructor pattern, in which you provide a constructor with only the required parameters, another with a single optional parameters, a third with two optional parameters, and so on…

    The telescoping constructor pattern is essentially something like this:

    public class Telescope {
        final String name;
        final int levels;
        final boolean isAdjustable;
    
        public Telescope(String name) {
            this(name, 5);
        }
        public Telescope(String name, int levels) {
            this(name, levels, false);
        }
        public Telescope(String name, int levels, boolean isAdjustable) {       
            this.name = name;
            this.levels = levels;
            this.isAdjustable = isAdjustable;
        }
    }
    

    And now you can do any of the following:

    new Telescope("X/1999");
    new Telescope("X/1999", 13);
    new Telescope("X/1999", 13, true);
    

    You can’t, however, currently set only the name and isAdjustable, and leaving levels at default. You can provide more constructor overloads, but obviously the number would explode as the number of parameters grow, and you may even have multiple boolean and int arguments, which would really make a mess out of things.

    As you can see, this isn’t a pleasant pattern to write, and even less pleasant to use (What does “true” mean here? What’s 13?).

    Bloch recommends using a builder pattern, which would allow you to write something like this instead:

    Telescope telly = new Telescope.Builder("X/1999").setAdjustable(true).build();
    

    Note that now the parameters are named, and you can set them in any order you want, and you can skip the ones that you want to keep at default values. This is certainly much better than telescoping constructors, especially when there’s a huge number of parameters that belong to many of the same types.

    See also

    • Wikipedia/Builder pattern
    • Effective Java 2nd Edition, Item 2: Consider a builder pattern when faced with many constructor parameters (excerpt online)

    Related questions

    • When would you use the Builder Pattern?
    • Is this a well known design pattern? What is its name?

    Interpretation #2: The constructor does a lot of work that costs time

    If the work must be done at construction time, then doing it in the constructor or in a helper method doesn’t really make too much of a difference. When a constructor delegates work to a helper method, however, make sure that it’s not overridable, because that could lead to a lot of problems.

    Here’s some quote from Effective Java 2nd Edition, Item 17: Design and document for inheritance, or else prohibit it:

    There are a few more restrictions that a class must obey to allow inheritance. Constructors must not invoke overridable methods, directly or indirectly. If you violate this rule, program failure will result. The superclass constructor runs before the subclass constructor, so the overriding method in the subclass will be invoked before the subclass constructor has run. If the overriding method depends on any initialization performed by the subclass constructor, the method will not behave as expected.

    Here’s an example to illustrate:

    public class ConstructorCallsOverride {
        public static void main(String[] args) {
            abstract class Base {
                Base() { overrideMe(); }
                abstract void overrideMe(); 
            }
            class Child extends Base {
                final int x;
                Child(int x) { this.x = x; }
                @Override void overrideMe() {
                    System.out.println(x);
                }
            }
            new Child(42); // prints "0"
        }
    }
    

    Here, when Base constructor calls overrideMe, Child has not finished initializing the final int x, and the method gets the wrong value. This will almost certainly lead to bugs and errors.


    Interpretation #3: The constructor does a lot of work that can be deferred

    The construction of an object can be made faster when some work is deferred to when it’s actually needed; this is called lazy initialization. As an example, when a String is constructed, it does not actually compute its hash code. It only does it when the hash code is first required, and then it will cache it (since strings are immutable, this value will not change).

    However, consider Effective Java 2nd Edition, Item 71: Use lazy initialization judiciously. Lazy initialization can lead to subtle bugs, and don’t always yield improved performance that justifies the added complexity. Do not prematurely optimize.

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

Sidebar

Ask A Question

Stats

  • Questions 443k
  • Answers 443k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Try using the click event instead. It seems to work… May 15, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer You can only do this with javascript, using the navigator.plugins… May 15, 2026 at 6:10 pm
  • Editorial Team
    Editorial Team added an answer I found the problem. The Page_PreInit was being called before… May 15, 2026 at 6:10 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.