Forums Register Login

What is the differance ?

+Pie Number of slices to send: Send
Hello,
I have a basic questions in the following code snippent what is the best way of declaring the mp object..which will take less memory..
regards,
Arun


[ April 26, 2002: Message edited by: Dirk Schreckmann ]
+Pie Number of slices to send: Send
They will take the same memory. The only difference is when the object is created, during the construction of the class, or when the method is called, the latter being a case of delayed initialization.
--Mark
+Pie Number of slices to send: Send
Thanks for you reply...
Which one you prefer?
Arun
[ April 27, 2002: Message edited by: arun mahajan ]
+Pie Number of slices to send: Send
The reason for delaying initialization is to allow the delaying the creation of memory intensive objects until the last minute. If this fellow is going to be HUGE then you might want to delay - and then null out that variable as soon as possible.
Otherwise it is probably better to create the object at the place the variable is declared. If the initialization is too far removed from the variable declaration you run the risk that the reader will have forgotten the "type" of the variable by the time you get around to putting something in it.
Saving programmer time is a big issue also.
Whip out those weird instruments of science and probe away! I think it's a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 522 times.
Similar Threads
How to listen toolbar buttons?
How to set this component?
why this component access is multiplying?
Why this object gets null in actionPerformed
Can you help me to write better code ?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 23:57:01.