View this PageEdit this Page (locked)Attachments to this PageHistory of this PageHomeRecent ChangesSearch the SwikiHelp Guide
Hotspots: Admin Pages | Turn-in Site |
Current Links: Cases Final Project Summer 2007

CS 2340 class advice and smalltalk help by Tyler Hastings

CS 2340 class advice and smalltalk help by Tyler Hastings

Useful tidbits for Smalltalk and CS2340 in general

Hey guys I thought id share some useful things that I found out while working on my CS2340 project. While using Smalltalk I found many things to be frustrating due to the poor debugging mechanism in visual works. So I am going to talk about problems that I had as well as solutions to these problems and other useful information about the class. First I will start off with useful information about the class.
Look at the T-square resources

First things first LOOK AT THE SAMPLE CODE posted on t-square. At the start of the semester there are a few individual coding milestones where you are asked to complete fairly easy tasks, but since you will be just starting out with Smalltalk they can often times become difficult! However, if you would take the time and look at the example code it is all there for you. There may be some things that are not but after having looked at the examples you should have a much easier time.

Use the old WIKI
The old wiki has everything you could possible need for the class on it. There is old code from previous semesters, old UML diagrams, old CRC cards and tons of other stuff. This is really useful for when you need an idea or are stuck with a bug. Also view the links that are posted on here. My favorite link is this: The short video clips posted here are really useful and actually interesting. You can also search the videos and find ones that will help with what you are working on.

The Store in Visual Works
As the teacher shows in class ALL CODE FROM PREVIOUS SEMESTERS IS POSTED HERE! I repeat all code from previous semesters is here. Just search for 2340, CS2340, or group names. This is a great place to go for Smalltalk syntax help, GUI help, or basically just help with your project. If you are stuck on something someone in a previous class probably had to do a very similar task and their code is in the store. Do not forget about this! It is very easy to over look this and think that since the projects are different that they will be of no use. This couldnít be any further from the truth. Use this resource, it is amazing.

C:Program Files/Cincom/vw7.6nc/doc
Trust me the contents of this file will be your best friend when you are trying to do something new or when you are debugging. All of these documents are great for when you know what you are trying to do. They often times have examples and will take you step by step on how to do certain things. The one place that will not really be helpful is GOOGLE.
NO. Smalltalk and Google do not mix very well. Unlike other CS classes where you can find useful information all over Google searches, this class is different. Not very many people use, used, or are going to use Smalltalk, therefore there are not many examples. That is why the WIKI and the documents that come with visual works are so important. The WIKI will point you to some sites that have examples and other things. The site that I used the most is the one posted above with all of the daily Smalltalk examples.

Get a group early and make sure you like them
Since this is a group project it is very crucial who you have as your teammates. I would suggest that you try and diversify your group. Get at least one person who will be able to design the GUI for your project because as we all know most CS majors are unable to do this well. Get a couple of people who are able to code well and know how to debug code. It is often times hard to debug in Smalltalk so knowing how to debug on your own will help. Lastly, I would suggest to get a person who knows how to create and setup a database. This will be very useful when your group is trying to get extra credit during the semester.
Another key thing with a group is how well you can work together. It would be great if you all were amazing coders, however if there is no structure to the group and you are unable to mesh correctly then the group will end up failing in the long run.

Do some work yourself
If you get put into a group that works hard and all the other people do all the work then you will not be very pleased when the time comes to get a test back. Make sure that you code some yourself! As we all know practice makes perfect, and this goes along with coding. If you do a good bit of coding on the project, when it comes test time the coding question will be so easy.

DO NOT wait until the last minute
Do not wait until the last minute to try and jam in a coding session to finish up a big milestone. This is exactly what my group did and it was horrible. There were multiple times where we had to be in the College of Computing until 4 in the morning working on cs2340. Itís not that the project was overwhelming but it did require a lot of work and time. If you can get the project divided up evenly and set your own dates where each member was to have their own parts due you will be fine.

The GUI can cause problems
Our project was to create a hospital management system. To implement this in code was not too bad, however when we went to hook this up to a GUI we ran into all kinds of problems. Itís not that we had trouble making the GUI, itís that there were so many more cases that came up as we proceeded. For instance when making a button to add a room, we thought this would be a simple dialog warn box that allows the user to type in a String and then create the room off of that... not the case. We ended up having to make it its own window that allowed you to type into a text box. We also had to make sure that room number was not used previously; we had to give it a capacity for the number of patients it could hold, make sure it couldnít be deleted with patients in the room, make sure the patient knew their room, and a bunch of other things. So do you see how simple things can end up being tedious? And that was just one of many situations that turned out to be longer than expected.

Do the Extra Credit
This is key! Most likely the extra credit will make a grade letter difference. The teacher offers tons of extra credit opportunities that you just have to be willing to do. Some of them do take a lot of work but usually they are not that challenging. Also start on them early. There are a lot that you can do at the start of the year. My thoughts on this are that your group should add some to the project and just assign them out like they are not extra credit. If you do this then you have a great chance at getting an A in the class.

Keep in mind that this class is not just the project
Even though you will be spending most of your time for this class just working with your group remember that there are 2 tests and what he talks about in lecture will be on them! Some people forget this because several of the topics from lecture do not need to be directly applied to the project. A lot of the information is just useful CS knowledge that you will probably use later on in your CS career.
The tests are not that difficult if you study. There are a lot of things on them that you just have to memorize. For the final we were allowed a cheat sheet so this helped a little, but the final was cumulative so there was a lot of information. Look at the review page, a lot of the old questions will be very similar to the ones you will see on your test.

Smalltalk Help/Advice

In this section I am going to go over some things that gave me problems and other things that would have been useful to know before working on certain parts of the project.

value, asValue, and asString
If you can learn where to place these three commands then I promise that your errors will be cut in half and you will spend much less time debugging your program. The asString is simple, just remember to put this after values that are not strings when you want them to be represented as strings. The other two can be sort of confusing at times. They are both going to be used a bunch when you are making your GUI. The value command will get a value out of a value holder such as a drop down box, or a text field. You will also have to use the asValue command sometimes in order to use the value that you have obtained. If you look at the sample code that is posted onto t-square at the beginning of the semester there are some very simple examples of how to use these.

One of our tasks was to add a pie chart. There is useful documentation on how to do this that came with visual works. All I want to say about this is that you HAVE to have the BGOK parcel loaded to even begin to create a chart. Also if you create your code and you want someone else to be able to use it make sure they have this downloaded as well.

This is just a parcel that you should download. Make sure that all of your group members do. If they do not then code will work for some people and it wonít work for others. Without this sometimes the value and asValue work funny. Just make sure you have it or else your team will keep changing the code.

Installing a canvas
When installing a canvas for the first time it goes to the ďnoneĒ package. From there you need to move it into the correct package so that it can work with your program. Iím not sure why it does this, it is very weird and annoying but this is what happens. SO just make sure to look here.

Parcel Manager Ė Environment Enhancements Ė RGBcodehighlighting
This will make it so that small talk colors variables and other things. This is great and a must have.

() are your best friend
These are very important in Smalltalk. If you do not have these and try to do something like do: ifTrue: catch: then you will receive an error saying unknown function. That is because it is trying to look for a function that has all three of these together opposed to them being their own functions. So just remember to use () around different pieces of code so that you wonít confuse Visual works.

Now let me go into some Smalltalk code that should be of use for the class.

Storing an object in a dropdown list
This was one problem my group had while coding. In an early individual milestone we were asked to create dropdown boxes that contained strings. This was very simple. Later we needed to store the Doctor object into the drop down list. A simple way to do this is to make a doctorToString method as well as a string to doctor method. They looked something like this.

   stringToDoctor: aString
	| list temp |
   	   list := appmodel hospital doctors.
	   temp := aString.
	   list do:[:each | ((each fname , ' ' , each lname) = temp) ifTrue:[^each]].

   doctorToString: aDoctor
	   name := aDoctor fname , ' ' , aDoctor lname.

Then what we basically did when we initialized the window was create an instance of our appmodel and went through our doctors list and converted them to strings so that they could be held by the drop down list. It looked something like this:

     appmodel:= anAppModel.
     doctors := List new asValue.
     (appmodel hospital doctors) do:[:each| doctors value add: ( self doctorToString: each )].

Then after this all you have to do is convert this string back to a doctor(using stringToDoctor) when the user selects the doctor from the drop down list.

JBOSS for saving
This is a very easy way to save your project. All we had to do was save our hospital and users. The code below shows how we went about doing this.
    	| boss |
	   "Saving, so open boss on a write stream and put our root object"
   	   boss := BinaryObjectStorage onNew: 'hospital.rec' asFilename writeStream. 
	   [boss nextPut: hospital; nextPut: users ] ensure: [boss close].

JBOSS for loading
It was also very easy to load a project. Here was our code for this:

	"user wants to load using BOSS"
	| boss array|
 	   "Loading so open boss file on a read stream" 
	   [boss := BinaryObjectStorage onOldNoScan: 'hospital.rec' asFilename readStream.
   	   [array := boss contents] ensure: [boss close]. 
     	   "remember boss returns array, so to get actual root object, we grab first element"
  	   hospital := array at: 1.
	   users:= array at: 2.]

This code was able to get our two objects that we wanted, the Hospital and the users.

And that ends my talk on cs2340 and Smalltalk. I hope that this document was useful for all of you!

Links to this Page