From leavens@cs.iastate.edu Tue Apr 22 16:45:54 2003 Date: Tue, 22 Apr 2003 16:44:25 -0500 (CDT) From: Gary T. Leavens To: Carl Cc: Staff for Com S 362 Subject: Re: Java question for 362 project. Hi Carl, On Tue, 22 Apr 2003, Carl wrote: > Dr Leavens, > I am attempting to cast an Object into an array in java. I am using the > Java.sql package. There is a method that returns a java type array from the > type java.sql.Array. I would like to store these results in an array(a 2- > dimensional array) is what i envision. But i cannot figure out how to make > java realize that the object returned from getArray() is actually the java type > array. If the array you get back holds objects of type Foo, then you should be able to write: (Foo[]) db.getArray() to cast the result. > Also i was wondering if it is possible in java to make an array of arrays. > A 2 dimensional array that does not need to have a type specified. such as > int twoDimension[x][y]. I would like to be able to declare an array of arrays, > and be able to have various types stored. IE.. one element in the array stores > an array of strings, another element in the array stores an array of ints etc... > Any help that you can provide would be very helpful. This requires the use of subtyping. Declare it as Object twoDimensional[][]; You'll have to use wrappers (like Integer) to store basic value types (like int) in it. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@larch.cs.iastate.edu Wed Apr 23 20:57:27 2003 Date: Wed, 23 Apr 2003 20:42:15 -0500 (CDT) From: Gary T. Leavens To: David Gillingham Cc: Tongjie Chen Subject: Re: [CS 362 HW10] Interaction Diagram Qs Hi David, On Wed, 23 Apr 2003, David Gillingham wrote: > In designing the diagrams for the second iteration, our group has come up > against some questions. In this iteration, we are implementing our > interface with the database portion of our project. We have designed a > DatabaseAdapter object which is implementing the basic features for this > iteration (adding, removing, finding records). This adapter then interfaces > with a MS Access database through the JDBC API. All this object is really > doing is generating SQL statements and sending query results to our UI. Okay, that sounds fine. > Additionally, we are implementing a use case, Sort Files, which shows the > user a list of sorted files in his/her personal database. > > Here are my questions: > > 1. How would I show these interactions in the interaction diagrams? > For example, in the Add File case, we are specifying to the database handler > a path name of an MP3 File on the local PC. Then we create an instance of > our MP3 class, and read in the file's metadata (tag info). We then use > these strings that are returned and pass them in a function call to the JDBC > API (which then stores the info in the database). How do we show these > interactions with the API? One thing you probably want to see is figure 23.2 in Larman's book. Note in particular the dog-eared box at the top right of the figure, which points out the notation for calling an instance of an adapter that implements a particular interface. See figure 23.9 and 23.14 for another example. There should be an instance of an class, probably a facade object, that implements the JDBC API, so you would show this interaction similarly to those in the figures I cite above. If you come to my office, I can try to draw a diagram for you. > 2. The second is related to the first-previously I mentioned a Sort > Files function. This allows the user to sort the database by some specified > criteria (by Artist, Album, etc.). All that we did to accomplish this was > write a hook in the GUI code to sort the displayed files, so that by > clicking on a table header it automatically performs the specified sort, all > through the GUI. At no point are any other classes referenced. How would > we write an interaction diagram for this? I was under the impression that > IDs are UI agnostic. No, you can draw an interaction diagram for the user interface also if you wish. You use the same notation, but just make it clear that it's in a different layer. This seems like it might be a good use of the "Strategy" pattern. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ------------------------------------------- From leavens@cs.iastate.edu Sat Apr 26 21:36:57 2003 Date: Sat, 26 Apr 2003 21:24:38 -0500 (CDT) From: Gary T. Leavens To: Ritesh Desai Cc: Staff for Com S 362 Subject: Re: question hi Ritesh, On Sat, 26 Apr 2003, Ritesh Desai wrote: > Hey i am having trouble using the addTableModelListener method describe in the > API, the start of my class in my package is somthing like this > > public class TableSorterDemo extends JFrame > implements ActionListener{ > > I think i need to change it too > public class TableSorterDemo extends JFrame > implements ActionListener, TableModelListener{ > > but that gives me an error of "TableModelListener cannot be resolved or is not > a valid superinterface" Are you importing the package where TableModelListener is defined, javax.swing.event? Note that ActionListener is in a different package, you have to import both. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 ---------------------------------------------------- From leavens@cs.iastate.edu Sun Apr 27 15:32:02 2003 Date: Sun, 27 Apr 2003 15:30:45 -0500 (CDT) From: Gary T. Leavens To: Derek James Light Cc: Staff for Com S 362 Subject: Re: HW10 Hi Derek, On Sun, 27 Apr 2003, Derek James Light wrote: > Dr Leavens, > > The hw requires that we write Junit test classes for 6 of our classes, > currently we do not have 6 classes even with a gui class. Should we try to get > more classes or just write the test classes for our current classes. > If you don't have 6 classes, just write tests for the ones you have. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@cs.iastate.edu Sun Apr 27 22:05:54 2003 Date: Sun, 27 Apr 2003 22:05:11 -0500 (CDT) From: Gary T. Leavens To: David Gillingham Cc: Staff for Com S 362 Subject: Re: HW10 JUnit Qs Hi David, On Sun, 27 Apr 2003, David Gillingham wrote: > For our project, we have run into a couple snags with JUnit rquirements. We > have a database handler class which directs traffic for the JDBC calls. Should > we be writing a JUnit class? How exactly would we be testing it? Yes, you should test that. Think about what transformations of the database it should make; for example, when you add a relationship to the database, you should be able to query to see that it is there and that the size has increased by one, etc. > Secondly, we used an ID3 tag library to implement a fraction of our code. Are > we required to test this prewritten code? No, you don't have to do that. > Thirdly, we will not, in any way, have enough classes to meet the 6 class > testing requirement. Is this a big problem? That is okay. If you test each of the classes you have written that will be enough. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@cs.iastate.edu Mon Apr 28 00:03:40 2003 Date: Mon, 28 Apr 2003 00:02:59 -0500 (CDT) From: Gary T. Leavens To: Joe Lahart Cc: cs362s@cs.iastate.edu Subject: Re: jUnit tests on hw10 Hi Joe, On Sun, 27 Apr 2003, Joe Lahart wrote: > I am wonder if you could give a little advice on selecting classes to do > Junit tests on. To see all of our classes it might be best to refer you to > our class diagram: > http://www.cs.iastate.edu/~jlahart/cs362/design-model.shtml > anyway the types of classes that we have are pretty much: > GUI classes that extend Jframe > ButtonHandler classes > Our start and stop classes > And database classes that interface with a database. > I guess I don't know a good way to write Junit tests for any of these types > of classes since all we have really done in class is more mathematical type > things. If you have any suggestions for a good process to follow I would > appreciate the advice. > > Thanks > Joe > (The code on the web page is up to date too if it would help you to see > that) Certainly you should write JUnit classes for the classes that interface with the database. You cana test things like, if you add a record, does it appear in the database, etc. I can see your point about the GUI classes and the start and stop classes. I'm not sure why you have the start and stop classes in some sense; what data do they encapsulate? If nothing else, just test the database access classes. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 From leavens@cs.iastate.edu Tue Apr 29 22:03:18 2003 Date: Tue, 29 Apr 2003 21:52:17 -0500 (CDT) From: Gary T. Leavens To: Adam Sanford Cc: Staff for Com S 362 Subject: Re: Hw11 Hi Adam, On Tue, 29 Apr 2003, Adam Sanford wrote: > Just an fyi, the due date for hw11 says april 8th, instead of may 8th in > hw11.txt Ah, I see it. You are referring to the "File date" which is when I made up the homework, and appears in parentheses after the title. The due date is below in the text of the problem, which, as you say, is May 8. Thanks, -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 --------------------------------- From leavens@cs.iastate.edu Wed Apr 30 23:52:12 2003 Date: Wed, 30 Apr 2003 23:51:52 -0500 (CDT) From: Gary T. Leavens To: Carl Cc: Staff for Com S 362 Subject: Re: Java Question Hi Carl, On Wed, 30 Apr 2003, Carl wrote: > Dr. Leavens, > I was wondering if it is possible, in java, to write a destructor for an > object. Being able to do so would be helpfull in putting the finishing touches > on my group project. There are object finalizers, but they aren't guaranteed to ever be called. Such a method has signature protected void finalize() throws Throwable What are you trying to do with this kind of thing? If you want to always do something at the end, you should have a method that you call yourself in the code to do it, and don't rely on finalize. -- Gary T. Leavens Department of Computer Science, Iowa State University 229 Atanasoff Hall, Ames, Iowa 50011-1041 USA http://www.cs.iastate.edu/~leavens phone: +1-515-294-1580 -----------------------------