Separate interface and implemenation problem..

T

Tom Anderson

As Steven picked-up on, my intention was to define a kind of interface for
static methods, not replace classes of static methods with interfaces. I
think such an static interface would be useful for various kinds of factory
patterns.

// not real code
public static interface MyFactory {
MyObject makeObject(); // implicitly static and public
}

//...

public class MyObject implements static MyFactory {

public static MyObject makeObject() {
...
}
}

Or something like that...

This is a perennial problem. Here's what i came up with five years ago:

http://c2.com/cgi/wiki?ConstructorObject

Thinking about it, though, another solution would just be to load a
factory class, Class.newInstance it, and then get instances of the class
of interest from it, without ever addressing the class of interest
directly.

tom
 
L

Lew

Steven said:
That first 'static' is already allowed, and has a meaning, though I

Only for nested types.
think it's redundant (right?).  Nevertheless, I wouldn't like to claim a
new meaning for it at this stage.

JLS s. 8.5.2:
Steven said:
But this marking seems unnecessary.  Why does it matter that someone
implements MyRunnable non-statically?  The user probably doesn't or
shouldn't (need to) care.  If it matters to the implementation, let that
be it's [sic] own look-out.

If it were possible for a nested interface to be non-static, the
client code would care. Consider the case of member classes. Inner
classes and static nested classes differ with respect to the outer
'this' and related idioms.
 
L

Lew

Mark said:
Steven said:
But this marking seems unnecessary.  Why does it matter that someone
implements MyRunnable non-statically?  The user probably doesn't or
shouldn't (need to) care.  If it matters to the implementation, let that
be it's [sic] own look-out.
If it were possible for a nested interface to be non-static, the
client code would care.

Steven said:
Sorry, no, I don't mean that - by 'this marking', I mean Mark's explicit
declaration that an interface type should be only be used in an
'implements static' clause, not a plain 'implements'.

Okay, I was confused by the remark,
That first 'static' is already allowed, and has a meaning, though I
which applies to nested classes. At this time no top-level type can
have a 'static' keyword.

I guess that means I miss your point, though. Client code most
assuredly cares whether a method is static or instance-level. In the
former case it invokes the method via the type name; in the latter it
instantiates an owning object through which to invoke the method.

The problem I have with the suggestion of a "static interface" is that
the suggestion to implement a static method in a concrete class
doesn't make sense. It's a very fundamental change to Java to have
"abstract static" methods. There is no override mechanism for static
methods. I foresee all kinds of problems if they tried to add one.

To have a non-abstract static method in an interface violates the
intent that an interface be purely abstract.

I agree with your point in that it doesn't seem painful to make an
instance through which to invoke methods. Anyway, aren't global
variables and methods somewhat antithetical to the spirit of object-
orientation?
 
C

charlesbos73

So you don't think it's a valid point that it's important to learn the
language as it is rather than to fight it at every turn?

You simply don't get it Lew.

It's not about every single of your sentence being "correct"
or "logical".

It's about the uber-rude way/tone you use to speak
to people.

How many times do people answer you "chill out" or something
similar?

How many times do people need to "justify" themselves and
their postings due to your constants overreactions and
verbal attacks?

It's your very attitude in this newsgroup that is for some
of us simply disgusting.

You're using dirty little intellectual tricks (that thankfully
some of us are all too accustomed to spot, even when english
is not our native language).

It's not about part x.y.z. of the JLS that your JLS-nazi
oriented mind can point to nor about statement 'x' being
right or wrong.

It's about you being a complete arse on this newsgroup.

I don't use ad-hominem on anyone but complete arsehole.

You're one of them.

When someone criticize one of your sentence
containing something like:
I have a brilliant idea:

and states that sarcasm doesn't help, the discussion
isn't about what your brilliant sarcastic idea is: it
is about your rude, spoily-childish way of formulating
your sentences.

Example:

Lew: "dirty motherfucker, don't you fucking realize that
in elementary algebra 1+1 equals 2"

commentator: "chill out man, no need to insult people!"

Lew: "what!? You disagree with the fact that 1+1 equals 2 ?"

Do you really lack the neurons allowing you to realize that
this is just slightly exaggerated?

You *do* drive people to insult and ad-hominem you.

Just how strong is your intellectual dishonesty?


I realized this when I read one of your post containing
a sentence going something like:

"... did you try to read xxx..."

Because of course there was a high probability the person
you were replying to was too dumb to understand, so that
person had to *try* to read, not too read.

Disgusting.

To me it's pathological. I'm pretty sure you suffer
from what is called "Delusion of grandeur". This
shows in your posts.

When you write "... did you try to read xxx...", people
don't care about your post.

People don't care about your "point" being logically
correct or not.

People do care about you being a total asshole
lacking the social skills allowing to conduct
a friendly discussion.

I pitty the persons in your team and there are times
when a good programmer needs to be fired because he's
lacking social skills.

I think you're one of those and I really wouldn't want
you on my team, no matter your level of knowledge.

For me you're an asshole and the more people dare to
ad-hominem you on this newsgroup the better, because
the way you're replying to people is unacceptable.

**** you Lew,

Charles Bossens.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,271
Latest member
BuyAtenaLabsCBD

Latest Threads

Top