File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Why have an interface DvdDatabaseRemote Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Why have an interface DvdDatabaseRemote" Watch "Why have an interface DvdDatabaseRemote" New topic
Author

Why have an interface DvdDatabaseRemote

Cory Max
Ranch Hand

Joined: Jul 20, 2005
Posts: 83
Hi All, I'm following the monkhouse/cam book and looking at their RMI implementation example. Why would we declare

then implement that single interface in our DvdDatabaseImpl class

Instead of just


Im sure there is a good reason, just don't know what it is.

Thanks,

Yeuker


There are only 10 types of people in this world... Those who understand binary and those who don't.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5599
    
  15

Hi Cory,

Did you try for yourself if your suggestions would compile and run successfully? I did when I was developing my assignment, and I posted my results in this topic.

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Well, I think they just wanted the code to be more readable...


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5599
    
  15

Roberto Perillo wrote:Well, I think they just wanted the code to be more readable...

I don't think it has anything to do with readability. But with being able to run your code

Have a look at following code:

Running the server and then the client, results in "Hello Roel" being printed to the console.

When I change the server's code to:

Running the server and then the client, results in a runtime exception:
Exception in thread "main" java.lang.ClassCastException: $Proxy0 cannot be cast to HelloService
at HelloServiceClient.main(HelloServiceClient.java:10)


Kind regards,
Roel
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2268
    
    3

Oh! At a first glance, I thought this was going to work normally. Living and learning
Cory Max
Ranch Hand

Joined: Jul 20, 2005
Posts: 83
Thank you very much for the replies. Very helpful.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Why have an interface DvdDatabaseRemote