Home arrow static arrow Java Programming [Archive] - is "interface" neccessary in java?
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - is "interface" neccessary in java?
This topic has 103 replies on 7 pages.    « Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | Next »

Posts:5,904
Registered: 04/03/99
Re: is "interface" neccessary in java?  
Jun 29, 2004 7:48 AM (reply 60 of 103)



 

I'm offended by that.

What do you mean "partially" !?

D.
 

Posts:9,091
Registered: 8/15/01
Re: is "interface" neccessary in java?  
Jun 29, 2004 8:16 AM (reply 61 of 103)



 

I'm sorry; from now on I'll remember that you only say averagely bad jokes.
I shall of cause punish myself further with a second pizza, and more vodka.
 

Posts:11,186
Registered: 06.04.04
Re: is "interface" neccessary in java?  
Jun 29, 2004 8:36 AM (reply 62 of 103)



 
I shall of cause punish myself further with a second pizza, and more vodka.

Thou shalt spank thyself with a pizza pepperoni on the bare buttocks five times.
And no anchovy toppings are allowed. You can keep the vodka though ...

Jos (the Spanish Inquisition)
 

Posts:648
Registered: 6/26/00
Re: is "interface" neccessary in java?  
Jun 29, 2004 12:40 PM (reply 63 of 103)



 
Wow, bringing out rockets, people. :)

It is something like this:

We both have machine guns and knives. I said, sometimes, a knife is more useful (optimal) than machine gun, for example, to use it to cut some food. Then all the sudden, people jump out and said, ok, let's fight, I will take all the machine guns and you will have all the knives, we will fight under the sun on the open. Haha, what is happening to these people?

Didn't you repeatly (I even said repeat repeatly) see my conditions:

...(and of course, with the earlier repeated conditions of you know the array size, and no change to the array size is needed).

Do I know the size of the array of the getPrime() method? Is there no change needed to the array size? Is that food I am cutting or people I try to kill?

There is this brought up:
{b]less optimization == less bugs because optimization == harder to follow

Does that imply to optimization == no good?

Well I showed a simple good optimization is easier to follow, that makes the above reasoning obsolete.
And to further proving my believe: optimization and number of bugs are not related

--
 

Posts:21,719
Registered: 98-02-20
Re: is "interface" neccessary in java?  
Jun 29, 2004 12:46 PM (reply 64 of 103)



 
Oh, my. Majinda, is that you?

"Does that imply to optimization == no good?"

Nope - where are you getting that?

Careful - this might land you in the Troll Hall of Shame, next to majinda and Zulfi the Monkey Lord.

%
 

Posts:5,904
Registered: 04/03/99
Re: is "interface" neccessary in java?  
Jun 29, 2004 1:34 PM (reply 65 of 103)



 

Fine, suggest an alternative example.

D.
 

Posts:11,186
Registered: 06.04.04
Re: is "interface" neccessary in java?  
Jun 29, 2004 2:27 PM (reply 66 of 103)



 
> for (int i=items.length-1; i>=0; i--) {<div class="jive-quote">items[ i ].doSomethings();}

The optomized version. Only on call to "items.length"
:D

Duh, *****; stand back --
for (int i= items.length; i-- > 0; )   items[i].doSomethings(); 

The ueberkool optomized version. No minus one thingy and a shorter for-loop line.
And above all: no slow superfluous curly brackets ;-)

kind regards,

Jos (the central optomizer)
 

Posts:6,750
Registered: 1/25/04
Re: is "interface" neccessary in java?  
Jun 29, 2004 2:53 PM (reply 67 of 103)



 
We both have machine guns and knives.

I don't agree with the analogy since machine guns and knives are completely different. Arrays and Collections are quite similar in their uses, so perhaps we could be talking about handguns and rifles.

Didn't you repeatly (I even said repeat
repeatly) see my conditions:

...(and of course, with the earlier repeated
conditions of you know the array size, and no change
to the array size is needed).


Do I know the size of the array of the getPrime()
method? Is there no change needed to the array size?

I can't speak for myself, but I wouldn't use an array even then. I acknowledge the compile-time type safety of arrays, which is a good thing. However, I rarely have problems caused by the type of objects in a Collection. I find Collections more intuitive and easier to use, they lend themselves better to future changes in usage (jschell, I know your opinion on this already) and the performance difference is meaningless in a real application. Now I'm not saying you're wrong to use arrays, just that I don't do it that way.

There is this brought up:
{b]less optimization == less bugs because
optimization == harder to follow

Does that imply to optimization == no good?

Optimization at the expense of anything else in the absence of a known performance problem == no good.

Well I showed a simple good optimization is easier to
follow, that makes the above reasoning obsolete.

And to further proving my believe: optimization and
number of bugs are not related

I disagree. Decreased readability is related to number of bugs, and optimization can[ decrease readability.
 

Posts:648
Registered: 6/26/00
Re: is "interface" neccessary in java?  
Jun 29, 2004 2:54 PM (reply 68 of 103)



 
Why is the fighting? All my first post in this thread trying to reply to is edsonw's comment of why use array, why not always use ArrayList.

and my reply was just these 2 sentences:


For performance and memory reason, you should work with pure arrays if the number of elements is stable and you can obtain it early.

List gives you nice dynamic sizing feature, but it comes with a price of larger memory foot print and casting overhead.


All these are true, and I don't think you would disagree. In specific context, you can add comments like "the performance gain is not significant", but the general statements are for "why use array". No example can be showed that using array on a stable array can introduce more bugs or make it harder to follow than using an ArrayList.

I am not disagreeing with any List usage, I will defend List equally if it should be used.

Somehow the thread leads to the topic of less optimization == less bugs, therefore don't optimize till it is broken. But I would think that we should use proper weapons to face bugs (better unit test system, proper review processes, good code reviews), and not to disapprove good optimization just to avoid the bugs. And we should certainly encourage clean and clear optimization.

--

 

Posts:6,750
Registered: 1/25/04
Re: is "interface" neccessary in java?  
Jun 29, 2004 3:00 PM (reply 69 of 103)



 

For performance and memory reason, you should work
with pure arrays if the number of elements is stable
and you can obtain it early.

List gives you nice dynamic sizing feature, but it
comes with a price of larger memory foot print and
casting overhead.


All these are true, and I don't think you would
disagree.

Then you're wrong. I do disagree. :-)

Somehow the thread leads to the topic of less
optimization == less bugs
, therefore don't
optimize till it is broken. But I would think that we
should use proper weapons to face bugs (better unit
test system, proper review processes, good code
reviews), and not to disapprove good optimization just
to avoid the bugs.

Good optimization means optimization that is undertaken to solve a known performance problem. As you're writing code, you should certainly design it to avoid unnecessary processing and particularly I/O, but in my mind that's not quite the same as performance optimization. Perhaps we're just using the word "optimization" differently.

And we should certainly encourage
clean and clear optimization.

Absolutely.
 

Posts:648
Registered: 6/26/00
Re: is "interface" neccessary in java?  
Jun 29, 2004 3:19 PM (reply 70 of 103)



 

For performance and memory reason, you should work
with pure arrays if the number of elements is stable
and you can obtain it early.

List gives you nice dynamic sizing feature, but it
comes with a price of larger memory foot print and
casting overhead.


Then you're wrong. I do disagree. :-)

ok, someone does disagree, my fault. :) I would like to know if this worth fighting for. I think you disagree with the first statement and not the second, right? And nobody disagree with the second statement, correct? Just to rule out some misunderstanding. :)

--
 

Posts:648
Registered: 6/26/00
Re: is "interface" neccessary in java?  
Jun 29, 2004 3:25 PM (reply 71 of 103)



 
Good optimization means optimization that is undertaken to solve a known performance problem. As
you're writing code, you should certainly design it to avoid unnecessary processing and particularly I/O,
but in my mind that's not quite the same as performance optimization. Perhaps we're just using the
word "optimization" differently.

I agree we may have used word "optimization" differently in some of our posts. But I was also clear that I disagree with the tone of "disappoving any optimization in development, wait till it is broken". That is a good reason for me to fight for some credits to the hard working optimization people in the back sence.

--
 

Posts:6,750
Registered: 1/25/04
Re: is "interface" neccessary in java?  
Jun 29, 2004 3:28 PM (reply 72 of 103)



 
Most of that hard work is probably wasted. If you spend time and effort optimizing something without knowing if it will be a bottleneck, well you're playing the lottery. Most methods are not bottlenecks, so chances are you're throwing work down the toilet. Now, if you're doing it for fun then that's another matter. :-)
 

Posts:648
Registered: 6/26/00
Re: is "interface" neccessary in java?  
Jun 29, 2004 3:47 PM (reply 73 of 103)



 
Most of that hard work is probably wasted. If you
spend time and effort optimizing something without
knowing if it will be a bottleneck, well you're
playing the lottery. Most methods are not
bottlenecks, so chances are you're throwing work down
the toilet. Now, if you're doing it for fun then
that's another matter. :-)

You are too certain on the first statement. There are success and failures, and most of other things land in the middle. It all depends how far you want to go in one direction.

Why do we care about hashing, binary search, red black tree, linear or logorithm access time in the Collection usage in development time then?

So we do have optimization in consideration in designing and coding when you far from knowing the bottlenecks.

And you think pushing to use array (under conditions) is too much, I can understand. But saying optimization consideration is going to be wasted before bottleneck showing up is making an extreme statement.

--
 

Posts:2,909
Registered: 13.8.2003
Re: is "interface" neccessary in java?  
Jun 29, 2004 10:35 PM (reply 74 of 103)



 
Why do we care about hashing, binary search, red black
tree, linear or logorithm access time in the
Collection usage in development time then?

Differences between algorithms don't result from micro-optimization, they're pure mathematics.
It's a different optimization altogether to switch to a better data structure than switch to array from a collection

And you think pushing to use array (under conditions)
is too much, I can understand. But saying
optimization consideration is going to be wasted
before bottleneck showing up is making an extreme statement.

Someone who spends a lot of time optimizing his code is wasting time in doing something that might be completely unnecessary. If he uses good design in his code, it's far easier to optimize the parts later on if necessary.
 
This topic has 103 replies on 7 pages.    « Previous | 1 | 2 | 3 | 4 | 5 | 6 | 7 | Next »