• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Understanding DBClient in Max's book

 
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As I understand so far about this interface, it serves two purposes:

1. wrap around on top of the low level db operation (which is the DBAccess interface); if the sampleproject takes a thin-client approach, then the business logic may go into this level.

2. expose the relevant db operation to remote/local client (at this layer, no extension to Remote b/c there will be another interface to extend Remote).

All methods in this interface throw IOException. This confused me a lot. In its implementation, I don't see the need to throw this ioex; so the #1 is irrelevant.

Is #2 relevant? No. Although I see some other threads (a search for "dbclient ioexception" will return) said this is for rmi's remote ex, I don't think so. the sample project compiles, in term of rmi, is because the remote implementation, DVDDatabaseRemote, throws both io ex and remote ex.

So, why is the ioexception thrown in DBClient? Is it related to the socket connection?

At least, I didn't see the need to throw IO ex in DBClient, so far, if use rmi.

Thanks for any input.
 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
DBClient has to throw an IOException because the DVDDatabaseRemote interface extends DBClient and DVDDatabaseRemote throws RemoteExceptions.

IOException is the superclass of RemoteException.

/J.
 
Joakim Eriksson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it looks like it does because of how exceptions works in overridden methods.

Max probably has a better explaination.
 
Andy Zhu
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Joakim, thanks for your reply.

DVDDatabaseRemote does extends DBClient and its implementation does throw remote ex; io ex indeed is super class of remote ex. However, look close to the DVDDatabaseImpl, methods all throw both remote and io ex's. If following what you said, you can remove io ex in these methods, then javac will complain to you. Therefore, the fact that io ex is super of remote ex has nothing to do here with the rmi interface (DBClient itself doesn't extend Remote!!! I think this is a misunderstanding also presented in some other thread). This is so far what I know. Yes, I guess there may be the reason for the ex being here and Max may explain to us better.

Thanks anyway.
 
Joakim Eriksson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no no no

I think that you can remove RemoteException from all methods that already throws IOException in the DVDDatabaseImpl though.

Of course you cannot remove the IOExceptions, then you wouldnt be implementing the DBClient.

--------------------------
As I mentioned in a post earlier in this forum it would be clearer if it worked like this:

DBClient extends DBUniversal
and
DVDDatabaseClient extends DBUniversal, Remote

in DBUniversal everything throws IOExceptions
in DBClient methods just throws what is needed for "local mode"
in DVDDatabaseClient methods throw what is needed for "local mode" and Remote

However DVDDatabaseClient does not extend DBClient.

This also means that connection in GUIController would be of the type DBUniversal instead, which makes sense since the controller should handle both local and remote connections.

The difference between the interfaces are just what exceptions they throw, and thus enforce on their implementations.

The way I'm suggesting gives more code (thus is more prone to error) but it is much less confusing in my opinion.

All comes from this:

public interface InterfA{
public abstract void method() throws ExceptA, ExceptB;
}

public interface InterfB{
public abstract void method() throws ExceptB, ExceptC;
}

public interface InterfC extends InterfA,InterfB{
}

public class MyClass implements InterfC{
public void method() throws ExceptB{ // cannot throw ExceptA
// or ExceptC or compile error
//code
}
}

however what we see in Max code is this:

public class MaxClass implements InterfC{
public void method() throws ExceptB,ExceptC{
//code
}
}

and it works because:

in this case:

public class ExceptC extends ExceptB{
}

or

that "RemoteException extends IOException".


----
This confused me a lot to start with. But maybe I'm less skilled than most other ppl reading his code. I can't explain it any better than this, so I hope you get what I'm saying.

/J
[ September 16, 2004: Message edited by: Joakim Eriksson ]
 
Joakim Eriksson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Damn, I think I understand now...

Max, my apologies, your code is fine, I'm just slow.
I misinterpreted DBClient to mean DBLocal, where it is just
really DBClient as it is written (and closer to what I suggested for DBUniversal). Basically you just rationalized away one interface.

Sorry,

/J
 
Andy Zhu
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


I think that you can remove RemoteException from all methods that already throws IOException in the DVDDatabaseImpl though.

Of course you cannot remove the IOExceptions, then you wouldnt be implementing the DBClient.



If this is the case, then why do we throw io ex rather than remote ex, while remote ex provides a bit more specific information? Or do we need to wrap some other ex into io ex in client side? Still not convencing.
 
Joakim Eriksson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Because RemoteException is a part of the RMI framework and we do not want to use anything related to RMI in our controller and "local code" to
"prove" that we are not using any network code. (a guess)

Otherwise there is no real benefit, unless you plan to use some code later that actually must throw IOException.

/J
[ September 16, 2004: Message edited by: Joakim Eriksson ]
 
Joakim Eriksson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In Max database his read/write methods in DVDDatabase do throw IOException.
Thus the DVDDbAdapter just passes them on (which is fine and logical).

For his code throwing IOException even in the "local code" makes sense, but most real assignments (SCJD) won't allow you to do that from the Data.java class.

Basically given the context of trying to retrofit his designs onto something similar to the SCJD assignment (my own assignment) I was confused. But it makes perfect sense once I understood what was the purpose of DBClient.

/J
 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have seen several references now to "Max's" book. What exactly is the title of this book? Several posts have mentioned that it was helpful to them and I may want to buy it myself.

Thanks.
 
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Brent,

ISBN: 1590590309

Actually, unless you know shag all Java, there is little to learn from it.

It gives a good overview for the exam and what it entails, but apart from that there is more depth to a box of rice-krispies. There is certainly more depth to most of the programmer cert books out there.
The worked example it doesn't work through, misses out a great deal of the important issues or neatly circumvents them!

I would personally recommend the Sybex book (ISBN: 0782428254) or even the mcgraw hill one (ISBN: 0072191694) although I've only given the latter a cursory flick though.

Although they are all out of date, I don't think there is anything available that is written in light of the current assignments.
 
author and jackaroo
Posts: 12200
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Brent,

The book in question is The Sun Certified Java Developer Exam with J2SE 1.4. In my opinion it is the best book for SCJD. It covers nearly every aspect of the assignment (although like every such book it does differ from the real assignment so as not to give away a complete solution), and explains how to work on the assignment from scratch - that is, how to develop a solution from the instructions you have been given.

Now if you are already a developer (not just a programmer who needs to be given clear instructions on every task) and you have already dealt with all the technologies used in the assignment, then you may not need this book - but then, why would you be looking for books anyway?

My best advice would be for you to see if any local book stores have a copy of the book, then go and read part of the book - see if it makes sense and speaks to you.

Regards, Andrew
 
Ranch Hand
Posts: 783
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I hate to disagree with Mike's assessment of Max's book, but I thought it was a wonderful starting point to the assignment. I purchased it and worked through the code before even downloading the SCJD assignment. When I did download the assignment, I was faced with a good deal of similarities between the book's sample app and the assignment.
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Paul Bourdeaux:
I hate to disagree with Mike's assessment of Max's book...



It's okay, I realise I'm in the minority.
I think if the reader has the goal of getting through the certs as fast as possible, with little background in Java, then perhaps it is a good book. But personally having studied the language for 3 years before even taking SCJP, I found it a little too basic.
But then I think that most of the respected posters and popular design approaches on this forum are way out of scope for this cert.
I think when people read Mr X raving on about DAO or full MVC approach or even my Transfer objects they should take it with a pinch of salt and ask themselves is this really required, can I not simplify this alot for the sake of the cert.
I don't know how Anton has managed to get his desing to weigh in as light as he has (~20 classes 2000 lines of code IIRC). But that sort of weight is probably more what is expected from SCJD. I know that a common criticism/comment from Sun is that assignments are typically a little OTT.
 
Joakim Eriksson
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by mike acre:


It's okay, I realise I'm in the minority.
I think if the reader has the goal of getting through the certs as fast as possible, with little background in Java, then perhaps it is a good book. But personally having studied the language for 3 years before even taking SCJP, I found it a little too basic.
But then I think that most of the respected posters and popular design approaches on this forum are way out of scope for this cert.
I think when people read Mr X raving on about DAO or full MVC approach or even my Transfer objects they should take it with a pinch of salt and ask themselves is this really required, can I not simplify this alot for the sake of the cert.
I don't know how Anton has managed to get his desing to weigh in as light as he has (~20 classes 2000 lines of code IIRC). But that sort of weight is probably more what is expected from SCJD. I know that a common criticism/comment from Sun is that assignments are typically a little OTT.




Basically what you are saying is go for the easiest solution available, that still can be defended as fullfilling the requirements.

If you want your cert asap, I can't argue with that.

However, I did not choose the minimalistic path, and to me, this assignment is not only about the cert.

/J
 
Andy Zhu
Ranch Hand
Posts: 145
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I didn't realize my simple post has so many reply. As to the cert, I only has Max' book. However, I am not just doing cert for cert. More or less, you will learn from doing the project. I agree with Joakim, I take it as a learning process and try to learn as much as I can. So I have studied many tutorials, articles, books on various topics such as threading, swing, pattern, rmi, regular expression, etc. I am glad I chose to take this exam. But to the new beginner, I think Max' book is a good start but don't expect you can learn it the next day.

Good luck
 
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Seems that I agree with Andrew. If you're a developer already, then it's probably a reference manual. But, what's wrong with that?... I don't use custom RMI solutions or Swing much so it had some pointers.
 
mike acre
Ranch Hand
Posts: 197
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A reference manual is the one thing it most definitely is not.

And no I don't think the minimalist approach is the way to go because it is the fastest way to get cert I think it is the best way to go to meet the spec. Minimalist spec == minimalist approach. Note I don't mean boiler plate the lot. I think Max's approach in his book is spot on - this is minimalist. By all means use complex approaches as a learning exercise. Then discover the error of your ways and rip them all out for the submission.
reply
    Bookmark Topic Watch Topic
  • New Topic