Creating many new instances vs reusing them?

Posted by Hugo Riley on Stack Overflow See other posts from Stack Overflow or by Hugo Riley
Published on 2010-04-27T16:01:37Z Indexed on 2010/04/27 16:03 UTC
Read the original article Hit count: 260

Filed under:
|
|
|

I have multiple business entities in VB.NET Windows Forms application. Right now they are instanced on application startup and used when needed. They hold descriptions of business entities and methods for storing and retrieving data. To cut the long story short, they are somewhat heavy objects to construct (they have some internal dictionaries and references to other objects) created and held in one big global variable called "BLogic".

Should I refactor this so that each object is created when needed and released when out of scope? Then every event on UI will probably create a few of this objects.

Should I strive to minimize creation of new objects or to minimize number of static and global objects? Generally I am trying to minimize the scope of every variable but should I treat this business logic objects specially?

© Stack Overflow or respective owner

Related posts about instance

Related posts about scope