File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
A friendly place for programming greenhorns!
Big Moose Saloon
Register / Login
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
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"
I agree. Here's the link:
subject: Memory usage -- which is better?
Do we need synchroniation with Singleton Data class
Why this is compile time error
All times are in JavaRanch time: GMT-6 in summer, GMT-7 in winter
| Powered by
Copyright © 1998-2015