A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
Win a copy of
The Java EE 7 Tutorial Volume 1 or Volume 2
this week in the
jQuery UI in Action
Memory usage -- which is better?
Joined: Oct 27, 2009
Oct 27, 2011 14:14:24
I came across some code today that looks like this:
someMethod( getObjA().getObjB().getObjC().getName(); getObjA().getObjB().getObjC().getAge() );
Would it not be better, not only for readability, but for memory usage to do it like this:
ObjC objc = getObjA().getObjB().getObjC(); someMethod(objc.getName(); objc.getAge());
My thinking is that Java has to create a temporary memory space to hold whatever is returned by getObjA().getObjB().getObjC() each time.
Is that correct?
Author and all-around good cowpoke
Joined: Mar 22, 2000
Oct 28, 2011 08:12:05
Performance / memory use is not the issue here, the ability to debug and maintain the code is.
If any of those compound statements threw a
, where would you look?
"Premature optimization is the root of all evil"
Did you see how Paul
cut 87% off of his electric heat bill with 82 watts of micro heaters
subject: Memory usage -- which is better?
Why this is compile time error
Do we need synchroniation with Singleton Data class
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2014