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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T22:43:02+00:00 2026-06-01T22:43:02+00:00

My Peers always force me to use Spring for creating new instance of any

  • 0

My Peers always force me to use Spring for creating new instance of any object. As per as my understanding, Spring provides a platform to manage the Business objects more efficiently. Spring makes the architecture more modular and more flexible.

There are some instances where I feel not to use spring bean, and go for general method of creating new objects. But, my peers always forces to do it by giving excuses of performance improvement. I never find any article related to spring where the factor of performance mentioned.

Question :
If I am using spring beans for creating the object whether it improves the performance compare to creating new instances using “new” operator.

  • 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-01T22:43:03+00:00Added an answer on June 1, 2026 at 10:43 pm

    If you think rationally, how spring can be faster ? It’s wrapper over your code. It also goes through the default constructor/overloaded constructor which ever is applicable.

    e.g.
    import demo.dependency.injection.IAccount;

    public class SavingAccount implements IAccount {
    public static int SAVING_INT = 5;
    
    public SavingAccount() {
        System.out.println("Default constructor invoked!!");
    }
    
    @Override
    public int calculateInterest(int amount, int duration) {
        return (amount*duration*SAVING_INT)/100;
    }
    

    }

    Bean configuration:

    <!-- Fixed Account -->
    <bean id="FixedAccount" class="demo.dependency.injection.impl.FixedAccount">
    </bean>
    

    When you load the bean using application context, it will print

    ApplicationContext context = new FileSystemXmlApplicationContext("/Beans/SpringDemo.xml");
    Account myAccount = (Account)context.getBean("FixedAccount");
    
    
    Default constructor invoked!!
    

    However, here we need to understand other than performance there are other advantages.
    like
    – DI
    – Manageability

    So i think performance reason is not justifiable.

    Apart from that:
    Spring IOC frameworks provide way to create instances using the spring bean configuration. However, it does not stop you to create instance using the new operator.

    I would like to given an example where you may chose to use new instead of the spring bean.

    Lets say in your web application you have singleton bean which has different methods for the business logic and in each operation you may need new object instances for operation (method level variable are thread safe).

    Because if singleton bean has prototype bean then it will be invoked only once when singleton bean is invoked. Please go through this for complete understanding.

    http://static.springsource.org/spring/docs/3.0.0.M3/spring-framework-reference/html/ch04s04.html

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

Sidebar

Related Questions

Do I need to use the Peer Picker to find peers in the new
What are the chances of creating a P2P network where a set of peers
I have been creating a peer to peer connection for a new game, that
I'm new to ZooKeeper. This is what I need. I've a network of peers.
I have a small cluster of peers (e.g. 10 nodes) already publishing and subscribing
Let's say I have 3 or more peers connected to the same WiFi Access
I'm trying to get my head around Cappuccino. I'd like my StackOverview peers to
I heard from my peers that knowledge of sharepoint is going to be good
I want to send broadcast message to all peers in my local network. Message
We have a Navision server with 3 licenses. One license should ALWAYS be allocated

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.