Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > refactoring

Reply
Thread Tools

refactoring

 
 
Michael Jung
Guest
Posts: n/a
 
      08-09-2007
Lew <(E-Mail Removed)> writes:

> Michael Jung wrote:
> > http://www.velocityreviews.com/forums/(E-Mail Removed)-berlin.de (Stefan Ram) writes:
> >
> >> Roedy Green <(E-Mail Removed)> writes:
> >>> Places where multiple outputs would be useful:
> >>> 1. 2D and 3D co-ordinates, Cartesian to polar. 2. returning a value with a
> >>> status indicator about how good the value is.
> >>> 4. division return quotient and remainder.
> >>> 5. font/colour pair 6. find min, max average of a set.
> >> Yes, but actually I am not aware of a reason, why not to encapsulate
> >> these compounds in a class.
> >> The only argument I remember was »overhead«.
> >> This breaks down to
> >> - Notational overhead in the source code
> >> - Execution time overhead

> > - Garbage overhead.
> > This may turn out significant.


> Individual values would have to be collected; there's virtually no difference
> in collection of a container for those values.


No they don't. Imagine a method rerun passing values to a static result very
often. Even if not, the overhead for another object may be 1:2 (I.e. two ints
vs. two ints in a container.

> Weigh against the bug risk induced by separation of variables that belong
> together.


You would not need to have them separated logically or on code basis, never
more than a line apart.

Michael
 
Reply With Quote
 
 
 
 
Lew
Guest
Posts: n/a
 
      08-09-2007
Michael Jung wrote:
>>> - Garbage overhead.
>>> This may turn out significant.


Lew writes:
>> Individual values would have to be collected; there's virtually no difference
>> in collection of a container for those values.


Michael Jung wrote:
> No they don't. Imagine a method rerun passing values to a static result very often.


When did the result start having to be "static"? I understand neither what
you mean by the term in this context, nor how that influences GC overhead.

> Even if not, the overhead for another object may be 1:2 (I.e. two ints
> vs. two ints in a container.


How are you getting this ratio?

The cost of garbage collection is proportionate to the number of live objects,
not to the number being collected.

>> Weigh against the bug risk induced by separation of variables that belong
>> together.

>
> You would not need to have them separated logically or on code basis, never
> more than a line apart.


Separated is separated. "Close" is only good for horseshoes.

--
Lew
 
Reply With Quote
 
 
 
 
Michael Jung
Guest
Posts: n/a
 
      08-10-2007
Lew <(E-Mail Removed)> writes:
> Michael Jung wrote:
> >>> - Garbage overhead.
> >>> This may turn out significant.

> > Lew writes:
> >> Individual values would have to be collected; there's virtually no
> >> difference in collection of a container for those values.

> Michael Jung wrote:
> > No they don't. Imagine a method rerun passing values to a static
> > result very often.


> When did the result start having to be "static"? I understand neither what
> you mean by the term in this context, nor how that influences GC overhead.


They don't have to be, but they can be. We are talking about examples, where
multiple return values are superior to wrapper objects.

static int x;
static int y;

Compare

f(int x, int y) = { return x+y, x-y; }
x,y = f(x,y);

with

f(int x, int y) = { return new int[] {x+y, x-y}; }
int[] xy = f(x,y);
x = xy[0]; y = xy[1];

where the wrapper object is a (probably non-elegant) array.

Run this a "couple" of times. (Of course, the first example can't be run

> > Even if not, the overhead for another object may be 1:2 (I.e. two ints
> > vs. two ints in a container.


> How are you getting this ratio?


It's stated. The memory ratio is 2:3 on a 32bit machine, so the overhead ratio
is 1:2 (one part overhead compared to two parts necessity).

> The cost of garbage collection is proportionate to the number of live
> objects, not to the number being collected.


That's a different issue. I assume the live objects being equal in the above
examples.

> >> Weigh against the bug risk induced by separation of variables that belong
> >> together.

> > You would not need to have them separated logically or on code basis, never
> > more than a line apart.

> Separated is separated. "Close" is only good for horseshoes.


(Tell that to a horse.)

Michael
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Refactoring a while loop without if .. else - Java 6 05-13-2005 11:29 PM
What does "refactoring" of a project mean ? Anan H. Samiti Java 33 07-30-2004 08:07 PM
Odd Multi-thread behavior when refactoring Christian Bongiorno Java 1 06-22-2004 07:46 AM
Survey on refactoring activities using IDEs Sebastian Jekutsch Java 5 06-09-2004 06:15 AM
come learn all about refactoring Refactorit Java 0 02-22-2004 06:36 PM



Advertisments