Monday, June 22, 2009

Linked List Assignment

I thought about certain exploits to try and break the game, but couldn't find any surprising bugs in the assignment.

Somethings I tried were trying to change the data object or mess with the order in the list. Nothing proved very surprising.

One recommendation I might have is to restrict access to the user of LinkedListNode to allowing them to set the data info if possible.

Sunday, June 21, 2009

Linked List Project Complete!

Below is my process of going through the assignment.


- I looked over Soren's readme for the StudentLinkedList assignment, it looks pretty good. I modified a couple typos and reworded a few sentences for clarity.
-After installing the files properly to get the assignment working, I started by creating insertAfter(), getHead() and getLast(). After writing those three, when I run the program it "should" build and display and provided that I don't do too much clicking it shouldn't error. The program seems to hang, I haven't been able to resolve this issue yet.
-I decided to work on writing removeRemaining(). It should be easy since all I have to do is chop off the list at the desired point. The problem I have run into is that the SinglyLinkedList.class explains that @param predecessor a reference to the LinkedListNode that will precede the inserted nodes.
when the parameter is actually called "node" and there should not be any inserting in this function, period. I am assuming for the time being that the node is what the user wants to become the new tail and all subsequent nodes will be seperated. The garbage collector should handle that once I set node->next to null.
-The SinglyLinkedList.class also says I am to return the first node of the chopped off nodes. That seems really weird, maybe an explanation of why that would be necessary would keep me from being so confused here. Perhaps the user will be notified of the removed nodes? I have no idea.
-The SinglyLinkedList.class seems to be the victim of copy-paste. There's a lot of referencing to "inserted nodes" in delete/remove functions.



-Implemented the remaining function: findPredecessor, the program still hangs, so I haven't been able to test any of my newer implementations.
-Found out the program was hanging because my implementation of getHead() was not correct.
-Fixed all errors and have the program working really well now, I only found one bug, and that was when I tried to insert shapes "inside" another column. Soren pointed out to me that the insertAfter function also has to account for inserting multiple nodes at once, something I didn't get from the SinglyLinkedList.class.
-Program is complete.

Closing comments:

-The assignment is an excellent way to see a linked list implemented simply and effectively, it's very reassuring to see something as elaborate as this come together after coding something so simple.

-I found it difficult at times to know what each function is doing in relation to the project, that may be intentional on the author's part, however I found that it would have been useful to know. The functions weren't always clear as to what they were supposed to return or what the parameters being pass represented.

-Very clear and detailed descriptions for the functions would greatly increase the student's ability to provide the proper routines to make this project work.

Sunday, June 14, 2009

Summary of Adding Instruction to Linked List Game

- Sent copy of modified readme to Stephen
- Added description of linked list
- Added objective of assignment
- Did not modify set up and simulation sections
- Added summary of what functions are supposed to do
- Added how to get to comments on functions
- Included generic programming tips at the end
- Decided not to include details regarding methods for LinkedListNode
- Added comments to code

Adding Instruction to Linked List Game

I sent a copy of the modified ReadMe (now version 1.6) to my supervisor and Stephen.

Here I will discuss what I added/modified which I thought would help students complete the assignment:

The first thing I added was a description of a Linked List. I had no idea if the students/people this is given to know what a Linked List is. So I included a little description as to what one is and a little about linked lists. After that I included a little objective statement to summarize what the goal of the project was.

I left the set up instructions and the running simulation instructions alone. I didn't feel like they needed to be modified and were clear enough. I did include on how to get to the interface inside the linked list jar (since that java file had the comments needed to understand the assignment in full) and a dumbed down version of what was written in the interface.

At the end of the README I included a few general tips for programmer.

I considered adding methods in LinkedListNode that would be useful/needed but I assumed that the end user would know enough Java to be able to look at the information presented to them by Eclipse or NetBeans. If they really wanted to they could just look at the LinkedListNode class for its methods.

I also added comments to my code just in case it will be used for something later with this project.

Summary of Con. Linked List Assignment

- Discovered comments in interface for linked list game. This would've been helpful had I known about it from the beginning.
- Read I was supposed to have a "dummy" head to my list. I figured that might have been a case. Fixed code for linked list game.
- Fixed code so that it allowed a series of nodes to be inserted.
- nodeOrHeadToInsert parameter was confusing (and really long to type out). Fixed issues had with insertAfter
- Confirmed "search" and "from" parameter usage. Modified code. Discovered specific usage for comparison of data objects and "search".
- "node" parameter in the remove methods may be a confusing name for variable.
- Finished linked list program
- removeNext does not seem to be used in game.

Con. Linked List Assignment

Feeling frustrated with my program I decided to start digging through the jar file that I was given (the one for the linked list game). I finally found the interface for the different methods that I am supposed to implement, as well as some notes on what each objects. This would have been handy from the beginning.

After reading about getHead, I discovered I was supposed to have a dummy head for this linked list. That's not how I'd do it but I suppose it works. After I did that, then read up on insertAfter, I found out I did another thing wrong. Apparently I was supposed to be able to insert a single node or a list of nodes. Not something I'm used to as far as linked list operations go but it's not too hard to include. Another problem I had was the only parameter (besides predecessor) was the node to insert which was called "nodeOrHeadToInsert" which made me think the node could be a head, but after reading the notes on the function it can't be true. I haven't tested it a whole lot so maybe insertAfter does give me the "special head" node. Finally I moved on to fixing my findPredecessor.

The search object was nonintuative, as well as the from. After reading the interface notes, I discovered I was supposed to compare the data with this Object search. Didn't think you could do that since Java is stricktly typed but I managed to shake it a bit to make it work. My line of code came out to be something like this in the end: if(node.getNext().getData().equals(search)). Another problem I had was I had to guess what the "from" parameter was supposed to be for. I eventually figured out that it was supposed to be the point in the list I was searching from. More notes on the "from" variable would be useful.

Apparently node.getNext().getData() == search doesn't bode well with the compiler for one reason or another. Its the first thing that would come to mind for me, but if the compiler doesn't like it I guess I'll have to do it this way.

Once again, using the comments on the interface, I move on to removeNext and removeRemaining. I question the use of "node" on the interface. I'm not sure if using predecessor instead of node would be more useful. Perhaps it might be more intuative. That aside, I got the last two functions working.

With those last two methods complete, the assignment was done. If a student knows what they are doing, the assignment can be done under an hour. For the next step, I'll take the existing instructions then refine them before passing them on.

Note: After playing a little with the program, I was finding that the game never errored when I commented out removeNext. Is that method even needed?

Summary of Starting on the Linked List Assignment

- Decided to first do the assignment before attemtping to write instructions (I'm glad I did).
- Had problems knowing what to do with GetLast if list is empty.
- Got error with clicking on objects, program couldn't find what I was clicking on.