Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

cannot run Max' s code

 
lydie prevost
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I just downloaded Max 'DVD code and I am trying to understand.
Is it the final version?
Because there are a lot of things I don't undersatnd.
For example if you look at the GUIController class: Nowwhere is declared DVDConnector....
Same for DBClinet I had to import the db package.
I guess there is something I don't understand.
Can somebody help me with that.
Do I have the right version?
Thank you very much
- Lydie
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Posted by lydie prevost:
---------------------------------------------------------------------------I just downloaded Max 'DVD code and I am trying to understand.
Is it the final version?
Because there are a lot of things I don't undersatnd.
For example if you look at the GUIController class: Nowwhere is declared DVDConnector....
Same for DBClinet I had to import the db package.
I guess there is something I don't understand.
Can somebody help me with that.
Do I have the right version?
Thank you very much
- Lydie
---------------------------------------------------------------------------
Hi lydie, the downloaded code has two versions. Version1 is the base and we build our project on it to get version2. If you have downloaded the zip file both versions should be present, I think.
And coming to the GUIController class, the db package is already imported in the source code. Its the fourth import statement in the class as
import sampleproject.db.*;
So there is no need to again import it.
Coming to DVDConnector declaration, there is no need to declare it. As the methods in the DVDConnector class are static, we don't need to declare the DVDConnector class itself, we can directly invoke the static methods using the name of the class as what Max did.
I hope this helps. Thanks.
Satish Avadhanam.
 
lydie prevost
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have unzipped the 2 versions
But in version 2 my GUIController class does not have the import
Here is how it lokks:
package sampleproject.gui;
import java.io.InterruptedIOException;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.PatternSyntaxException;

/**
* Handles all interactions between the GUI layer and the data layer.
*
* @author Denny DVD
* @version 2.0
* @see DBClient
* @see GUIControllerException
*/
public class GUIController {
/**
* Indicates a local connection
*/
public final static int LOCAL_CONNECTION = 1;
/**
* Indicates a network connection.
*/
public final static int NETWORK_CONNECTION = 2;
/**
* Indicates no established connection.
*/
public final static int NO_CONNECTION = 0;
/**
* Holds a reference to the client interface of the <code>DVDMediator</code>
*/
private DBClient connection;
/**
* The default connection String.
*/
private String connectionString = "localhost";
/**
* Holds the current connection type.
*/
private int connectionType = GUIController.NO_CONNECTION;
/**
* The Logger instance. All log messages from this class are routed through
* this member. The Logger namespace is <code>sampleproject.gui</code>.
*/
private Logger log = Logger.getLogger("sampleproject.gui");
/**
* Creates a default <code>GUIController</code> instance.
*/
public GUIController() {
/**
* Creates a <code>GUIController</code> instance with a specified connection
* type.
*/
}
public GUIController(int connectionType) throws GUIControllerException{
this.setConnectionType(connectionType);
}
And I don't have DVDConnector stactic either
A lot of my files don't compile
I am not sure if I have the right version
When did you download yours?
Thank you for this quick response
_Lydie
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi lydie,
I downloaded mine a month ago. And the import statements look as below.
package sampleproject.gui;
import java.util.*;
import java.util.logging.*;
import java.util.regex.*;
import sampleproject.db.*;
//Choose the networking protocol by uncommenting the package you want to use
import sampleproject.remote.*;
//import sampleproject.sockets.*;
import java.io.InterruptedIOException;
/**
* Handles all interactions between the GUI layer and the data layer.
*
* @author Denny DVD
* @version 2.0
* @see DBClient
* @see GUIControllerException
*/
Here the sampleproject.db.*; is already imported. I think they are constantly updating the code by reading the feedbacks like that. So there might be changes in the code. If its not there, you can import the db package.
And coming to the DVDConnector class(remote package) now. What I meant to say is the DVDConnector class is not static but the methods of DVDConnector class i.e. getRemote() and getLocal() are static. In the GUIController class, the code using DVDConnector is like this.
public void setConnectionType (int connectionType)
throws GUIControllerException{
try{
if (connectionType == GUIController.LOCAL_CONNECTION) {
this.connection = DVDConnector.getLocal();
this.connectionType = GUIController.LOCAL_CONNECTION;
}
else if (connectionType == GUIController.NETWORK_CONNECTION) {
this.connectionString = System.getProperty("sampleproject.hostname");
if (this.connectionString == null){
this.connectionString = "localhost";
}
log.info("Using hostname " + this.connectionString);
this.connection = DVDConnector.getRemote(this.connectionString);
this.connectionType = GUIController.NETWORK_CONNECTION;
}
else {
throw new IllegalArgumentException
("Invalid connection type specified");
}
}
catch(Exception e){
log.log(Level.SEVERE, e.getMessage(), e);
throw new GUIControllerException(e);
}
}
As the methods of DVDConnector class are static, we don't need to have an explicit instance of the class. We can directly use the name of the class to invoke the static methods on that class. That's why we don't see any declaration of DVDConnector object in the GUIController class. All we need is to import the remote package, which has already been imported.
Hope this helps, thanks.
 
lydie prevost
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much and sorry for the delay.
I was away from my desk the last couple of days.
I have finally understood what happened.
I develope with eclipse and installed omode "UML plugging" , I wanted to generate the UML from max's code to understand it better, and I don't know exactly what I did but it seems that I altered the files ( mainly some imports) and that is why things did not make sense, I unzipped every thing again and it is like what you descrided.
Thank you and sorry it was my mistake
- Lydie
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Lydie, glad that it helped. Thanks.
 
Consider Paul's rocket mass heater.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic