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

A Small Squeak Tutorial


Group Programming Tips Morphic Strangeness Common Mistakes Uncommon Mistakes Goodies Files n such

General Info

Some rescources for quickly learning Squeak Squeak Basics - Start with this one. It quickly explains much of what you need to know. the Table of Babel - a table showing the differences between Squeak and Java. This page is relatively short. A Squeak Quick Reference - This ENORMOUS page contains a ton of info about the Squeak interface and different methods which you will use a lot. Will allow you to cope much better if you'd rather be on VI(M). The Api Swiki - Web page full of a ton of alphabetized fileOuts. Useless in it's current state because your image contains the same information and it is slightly easier to use. This page is larger than most dictionaries, not an easy read. At this point your are wondering what a Swiki is, Suffice to say that it is a web page which allows (through the use of HTML forms) anyone to add and edit pages. The Concept is that the fastest way to make a website is let everyone else do it (OpenSource for the Web). When Squeak stops working... 1. Keep a clean image around. - Eventually your image will get really big, or it will get messed up, or both. When it becomes a problem you will want to know you have a good fresh image laying around. Backup your original .image file. 2. When everything stops working - Press Ctrl + break, it should stop the infinite loop, if not, Panic... 3. Blowing up Squeak / SmallTalk is not as easy as blowing up C, but it is easier to crash than Java. You can not only crash the program your running and the 'image' with all of your code in it, but also the program running your program (the VM). So FileOut often. Saving is not enough, if the image gets corrupted your still out of luck, it is totally possible that you screw your image enough that you lose it completely, if you dont have a fileOut of your code you aren't getting sleep.

Group Programming Guidelines

Choosing teammates - Picking teammembers can be difficult. Sometimes it is a good idea to team up with a friend or a couple of friends. There are problems with this of course. Some Friends tend to enjoy each other's company so much that no work gets done. Very Often your best friends may be on a totally different coding level than you this is likely to cause frustration. Also Your teammates should share the same interest level. If you really want an 'A' and your friend would settle for a C the assignment will be problematic. Coordination - One of the most difficult things to do in any group project is to get everyone's code to work together. Adopt an interface in your design which assigns each person a section of code and then an interface so that the everyone know how to use everyone else's code without killing flexibility in programming around the unexpected stuff. In general a Good Design will save you big time when your project (and the group) is large. Programming in the same room is helpful too, although the States cluster (COC) is usually not the best place. Space and Time - The COC is a busy place, It will probably be packed full when your group wants to code your project. That means you wont necessarily get machines anywhere near each other and always the nice fast computers are taken. DONT CODE IN THE CLUSTERS. You need to find a nice quiet place where all of you can talk about design and implementation and you dont always need a 1:1 computer to person ratio. If one person is watching another code it is beneficial because there will be less bugs and TWO people understand the code instead of just one. Comprehension - Sometimes one group member will write some code that others will have to imitate. In this case it is rather important for that person to explain his code to the rest of the group. Otherwise they are likely to BANG thier heads into some rather tough problems trying to get anything working. I think we did fairly well on our project. The strong points in our project were the original design, Staggard coding, Massive effort. Design - our design fit the problem and the language pretty well. Only a few classes were added to our original design and I am pretty sure that none were deleted. The Classes we created dealt with initialization and a few surprises that were thrown at us in mid-development like a web interface. Staggard coding - It just so happened that often when a deadline was approaching, one of our teammembers would write some code - send the others the entire project with their changes - one of the others would pick it up and write some code - send everyone the new code... In this way everyone had all of the most current code while they were working on the project and no one else was working on the same code, also each send was the WHOLE project so the problem of big bang integration was circumvented. This does not work at crunch time, and it does not make use of all the benefits of object oriented programming. This is not the way a company would have their employees work on a project with the possible exception of a global company (Bob in UK -> Joe in Japan-> Fred in US-> Bob repeat ad nauseum). Massive Effort - Coding had to be started Well in advance of deadlines due to the lack of documentation, the confusion of morphic, and staggard coding. Also the sheer size of the project and learning a new language (smalltalk) meant there was a lot of time involved. Group members should know each other's schedules / plans. We rarely met as a group for this project but we kept in touch through email (A lot of email) and we knew who was working when and what they were trying to do. One of the subtleties of a Web Newspaper is that the Web changes a LOT. The parsers had to be rewritten a couple of times, THIS WAS WAY TIME INTENSIVE. I wrote the BBC reporter three times, twice from scratch. The reason I did not have to rewrite it after that was that I found the "low graphics" site which ws easier to parse and did not change as much. When working with a group of people, you are going to want them to write good comments. How to get them to do so is a subject for a psycology course. The Worst thing that happened to us was at the very end of the project, We were almost done but because of the MASSIVE crunch at the end of the year, and the fact that we all HATE morphic, some of our group decided it really wasn't worth it to do the last milestone. Looking back, it was a self fullfilling prophecy. We did come very close to getting our morphic viewer working, The roadblock came in the form of Morphic itself. Maybe if we had all worked on it the extra effort would have come up with the answer, as it was, well we came pretty close...

Morphic - Rant

Morphic is an Alpha - Playing with morphic using a mouse is easy, Getting morphic to work with code is HARD. Just because you can do something with the mouse and you know how to lookup how it is done means nothing when you try to scale that up and get YOUR project to work. The trick to morphic is finding the methods that you have to call and then CALLING THEM IN THE RIGHT ORDER! This is almost impossible to do because the order in which they must be called is NOT, OBVIOUS, DOCUMENTED, OR KNOWN. Trial and error ensues as you must first figure out why aMorph color: (Color blue) only works if called before certain other methods and after certain other methods. I spent the BULK of my time in Squeak trying to figure out the Language and the Syntax. This constitutes a major fault in my ability to code in squeak. I knew generally HOW to do what I wanted, I spent HOURS trying to get squeak to do it and I found NO help online Nor did anyone know how to do what I wanted to do. I spent the two whole days before the last milestone trying to get morphic to create three columns each with text and a picture. Could not do it. I cannot tell you how frustrating this is. I am getting a headache just thinking about it.

Common Mistakes

Placing an End of statement after the if block in an if else block ex. (a < 1) ifTrue:[ Foo foo: a. ]. <- Take this '.'out or get an error ifFalse:[ <- Error no reciever for this message Foo bar: a. ]. Forgetting to close open files aFile := StandardFileStream fileNamed: 'foo.txt'. ... aFile close. <- if you forget this, there is no warning and Normally your program runs fine, but every now and then... A Server time out After a 20 seconds, Squeak gives up when doing HTTPSocket httpGet: so trap it with [code that tosses chunks] ifError: [ run if error ]. To solve this particular problem I hacked it a bit. superGet: loc [HTTPSocket httpGet: loc ] ifError: [ ^self superGet: loc ]. Amazingly I never saw this little hack stall forever.

Uncommon Mistakes

This is the Uncommon mistakes section - perhaps I should have called it the 'Squeak Sucks' or the 'Squeak is a beta' section. (oh well) File Problems P: Files in the Squeak directory can usually be opened with aFile := StandardFileStream fileNamed: 'foo.txt'. There is one (really annoying) exception well at least in the Windows VM. If the image opened was NOT named Squeak2.7.image Squeak would not know it's home directory. This will cause your file open code to return nil every time and you wont be able to figure out why. S: Rename your Squeak image or tell the directory 'C:\squeak\foo.txt' Large Image File P: Your image has doubled in size over 1-2 months. S: Some strange thing happens with GUIs in squeak. It has something to do with subclassing Object when you should have subclassed Model. All of those things that you create get added to a list inside of Object, so they are NEVER garbage Collected unless you specifically call self breakDependancies. The smaller details of this strangeness like 'What do you mean "self breakDependancies"?' I do not know, My code increased the size of my image by .03MB every time I ran it. Errors in String asUnHtml P: String asUnHtml has a problem that my teammember Gary Herndon caught. It dies when it sees a &&; without a ;. So if the webpage has a floating &&; in it asUnHtml eats all of the characters until a ; is found. S: Gary created a new method stripHtml to circumnavigate this little problem. Gary's String fix Morphic programming P: It is REALLY hard to figure out how to do stuff WITH CODE (instead of a mouse) in Morphic. S: Try everything, Trail and Error. Just pick a method that sounds useful and use it. Save your code first though. 9 out of 10 times Squeak Will DIE. The other 10% of the time you just will not get the intended result. The Group that actually got their Morphic GUI Newspaper display working described the process as 'trying EVERY single permutation until it worked'. It took them DAYS to get text and pictures on the screen. Their Advice, TextMorph AvoidOcclusions does not work - dont use it. To get stuff on the screen properly you must call openInWorld, extent:, addMorph:, and position: correctly and in the right order... I could not figure out how to actually do this myself, here Questions On Final Milestone this could help. There may actually be a few good books out there on the horizon that could help. Of course, Whether that is helpful to you now... well, this is Tech... Jpeg issues P: Some Jpeg images crash the Jpeg Reader. This is because the Jpeg Reader is a 'Hack' alpha Jpeg reader and it does not understand a certain kind of 'tag' that sometimes appears in Jpegs. S: You can catch the error with [try this] ifError: [:var1 :var2| do stuff]. Or as my Professor always said "You have all the Source, Fix it" More Info:Questions On Final Milestone MultiThreading P: Having multiple threads/Processes in Squeak seems to be a problem S: Don't use multi processing, or the long answer is available:Web Deselection Milestone. Internet problems with Machines with greater than 1 NIC P: "Squeak doesn't know how to deal with multiple IP's for the same box. So, no, it won't work." Mark Guzdial. S: "you have the source..." Problems getting a server to run (PWS or otherwise) P: Some Squeak 2.7 VM's do not work right. see Andreas Raab S: Redownload the newest VM and it should magically work, If not then "continue dying". Need more Memory in the NT cluster? P: your code EATS RAM (memory) S: "Just a quick note for memory problems: NT, go to view->options->file types->(find the type corresponding to .image) ->edit->open->edit, and type in (for the CoC)(whatever drive):\Apps\Squeak\Squeak.exe -memory: 128 "%1" to get access to 128 megs while within squeak. If you need to make a "new" type for .image, do so making the open action as above..." Jared Ivey and Matthew Wolenetz.

Goodies, Files, Examples n stuff

CS 2340 CowebThe Top of the CoWeb, You will be going here a lot. Spring 2000 coweb Attachments - lots of neat stuff including: a Syntax Highlighter a AIM and ICQ client in Squeak (does both and more) Squeak Time's Newspaper - The best Paper in our class, Tons of example source. Lex and Yacc for Squeak, Kinda CS 2390 CowebThe Top of the Old CoWeb, There is a bunch of Cases and files here, Too many...

Other Surprises...

See the Spring 2000 Surprises page.

By Jeffrey Kwasha
Additions are greatly appreciated and should be added to the bottom

Last updated: 4-28-00
Jeff Kwasha
Jeff, this is your aunt least I think I am your aunt if you are my brother Robert's son. I was cruising in searching Kwasha, and I happened onto your site. What on earth is Squeak?

Jeff, This is your mother, please call home we miss you.
Just kidding... ha
Jeff, This is your wife, where the heck have you been? Your daughter is still waiting for your to come back home and bring her milk for her to go sleep !!!
PS. (dont wake me up if it's after 3AM)

Links to this Page