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

Questions on Spring 2005 M2

Edit Questions on Spring 2005 M2 here.

I have the places displayed in systemwindow as PluggableButtonMorphs. And the icons I add for people are added to this button usiong addMorph. But everytime I click on icon, it ssumes that I clicked on the button, since the icons are inside the button. I can see them and also grab them by click+al+ctrl and then in subMorphs, icon is there as an imageMorph that I can grab and move and stuff. But for some reason I cant add mouse click handler for this icon in the button. How can I make this icon to understand mouse clicks??


Perhaps you should try putting each icon in it's own button that has selectors which refer to the icon. – Andrew Sayman

Im trying to figure out how to parse XML documents in squeak. Anyone have any links or advice?
Here are two cases pages that may be of help to you: M5 - Persistence. and HOW TO USE DOMXML Andrew Sayman

I get a white border when I add an ImageMorph to a TwoWayScrollPane, that is larger than the ImageMorph itself. Is there any way to remove this white border?
Try fitContents – Andrew Sayman

I tried fitContents, and it doesn't seem to do anything at all. The white border is still there. I've called it before and after adding in the ImageMorph that I'm using. The only way I can think to do this is to somehow detect the size of the image I'm using and manually telling the TwoWayScrollBar somehow to fit its bounds to that. But even trying that, the border still exists. When doing "Transcript show: scroll totalScrollRange." the Transcript returns my image bounds in the following form: "0@0 corner: 688@460688@460", which seems a little odd. Any advice?

For class diagram, can I use QSEE, which only support java c++ and #c, to make it? since if I use QSEE then the syntax obviously look like one of these languages. Is there any other tool that support smalltalk?
do we have to list all the attributes and methods in it or we just list those that are important ?

> thank you!
How do I change the size of SystemWindow? I tried using extent.
I did - win extent:600@600. But it didnt work, The size still stays the same. how should I change it?

Try this (taken from the resize/collapse category of SystemWindow):
swin setBoundsWithFlex: (0@0 extent:600@600)

Also, taken from the example page that I posted below:
swin openInWorldExtent: 600@600

Andrew Sayman

I am having a problem with pluggableListMorphs. I am able to display stuff in the morph but am having problems on how to change stuff. If i try to send a fuction to selected:#function name and changeSelected: #functionName i get an error while it works fine if i send in nil.

I really need the error message from this to help you specifically, but I can give you some ideas. Firstly, changeSelected: expects a message that can accept a parameter, so you should be passing it something like #indexChanged: or #functionName:. Secondly, the reason it works with nil is because PluggableListMorph checks to see if you've given it nil and then does nothing. What's happening here is probably that it's trying to send a signal that doesn't accept the parameter it expects, or you've not implemented the methods in your model. You may want to have a look at this page for a sample, working PluggableListMorph – Andrew Sayman

for the "Users must be able to display the GUI by executing LocationViewer show." requirement, does this mean that show should be a class method for LocationViewer, which will open up the gui, or are we just supposed to be able to do "bob:= LocationViewer new. bob show."?
It's referring to a class method. – Andrew Sayman

How do you make a TextMorph that will not wrap lines if the user inputs more than it's initial width?

When testing the networking classes, is it ok to wrap testing for all network classes together in one big NetworkTest instead of having a test class for each of my network classes? It seems a lot more feasible to test all network functionality together (i.e. one test that starts a server and tests if a client can connect to it, send a message, etc)

Using a single SUnit class to test multiple networking classes is ok.


How do you make a TextMorph uneditable?
If you just want to display text, you should probably use StringMorph instead. Are you trying to do something different? – Andrew Sayman

In addition to Andrew's suggestion, you can call the message 'lock: true' on the TextMorph, and it will make it uneditable. – Troy Brant
As far as I can tell from my experiments in 3.5, that's not true. – Andrew Sayman

how do you modify the server path, implementing PWS.
ServerAction class serverDirectory method requires the path change.

How do we make a one line text editor? like JTextField. PluggableTextMorph always has that ugly scrollbar on the side.
PluggableTextMorph is a subclass of ScrollPane. ScrollPane has the very obviously named method hideScrollBar. That should work for you if you just want to make the scrollbar go away. – Andrew Sayman

where is the netchap.cs?

Even though Squeak isn't all that typed, should our diagrams still reflect types? They don't seem to make a lot of sense without them.

It seems you've answered you own question here. Squeak may not be very strongly typed, but you expect certain types, and your program fails if not given them. – Andrew Sayman

Okay, I just felt the pain of an infinite loop in squeak. And, I wasn't following the creed of my RPG roots from high school: SAVE OFTEN. So I just lost an hour and a half's worth of work. Is there a way to recover from an infinite loop in squeak (so that I don't go and cry in a corner more than once in this class)?


ALT-(period) . It'll break you out of that nasty inifinate loop. – Troy Brant

Also, your changes are not gone! See the 2340 Squeak FAQ , and scroll down to "Squeak crashed I've lost a lot of changes! What can I do?" -Lex Spoon

Two quick comments:

1. I said in class that you couldn't just copy the images to all the computers involved to avoid transferring images over the network. You can cache copies to make connecting more efficient, but you MUST support transferring images over the network.

2. A couple of people have asked about using 3.7 to either draw on particular packages or updates to the networking capabilities. You're welcome to use whatever version you want as long as you clear it with your TA in advance. I'm sticking to 3.5 in class primarily because 3.7 breaks some of the multimedia support in Squeak that I'll be talking about.


As a little helper for those of you that haven't already found a means to do your UML class diagrams. My group found the following tool that is free to download and seems to work very well for making class diagrams.
UML Sculptor
Its functionality is limited to class diagrams, but it is still a nice tool that doesn't impose certain restrictions on you while you're trying to use it ... (visio comes to mind!)
QSEE is most convenient for class diagrams of the tools available at GT.

Do we have to show Squeak classes in UML?
If some set of Squeak classes are critical to your design, and now showing them makes certain details unclear, then you should put them there. – Andrew Sayman

Are we permitted to post our icons and maps on a normal (non-squeak) webserver and load them into the client program via HTTPSocket httpGif: ?
That would take the fun out of using Squeak wouldn't it?

For Squeak UML Class diagrams, are class variables underlined?


Do we need to include accessors and modifiers in our UML Class Diagram?

UML is meant to capture only the essential methods.

When I use sixxString to send the object across the wire, is it possible to parse the sixxString back to the original data type?

Yes. SIXX provides methods for both writing an object out to a string and reading it back in.


I'm finding it really hard to sunit test my network code. Here's how I'm trying to do it:
[client sends a message to server]
[some time passes]
[client receives a message from the server]

Once the message is received I can set a boolean and check for that in my sunit test. The problem is the [some time passes] stage; execution of the test case will blow right by, without giving the server time to respond, so the test always fails. But if I try a Delay, EVERYTHING stops, so it's no good. I've even tried forking my assert statement, but that has the effect of invalidating it because it has no context in which to run, since the test case method has finished executing.


How about, instead of a Delay, looping until the server has done its thing? Inside the loop, call whatever method causes the server to do its processing.

Keep in mind, you don't have to set up a real server and client talking to each other. It may make a lot of sense to set up a server and then talk directly to the server over a socket.

As another tip, you can certainly add extra methods to your classes to make them easier to debug. For example, you might want to add a method that counts how many messages the server has received; then, have your loop keep going until 1 message (or hawever many are in the test) has been received.

Testable code can be a pain, but it's worth it. You will enjoy having code where you can start up each component individually to play with. -Lex Spoon

People have mentioned having problems with ArbitraryObjectSocket. Here's a fast attempt at a fixup: objSockHackFor2340.cs. It's not thoroughly tested.... Anyway, for the record, I wrote this code, and even I do not like it–I always use StringSocket instead. I wrote AOS just to show it could be done. Anyway, it's your program, and you don't have to write it how I would. Just be sure, if you use AOS, that you warn your TA to pre-load the above patch. Otherwise, your program will immediately crash when it connects to the network! -Lex Spoon

Are we required to send the image representation of the maps and icons over the network? or can we implement it using existing images stored on the client (and use a string-based network protocol with numbers representing each predefined map or icon, especially since ObjectSocket seems to be broken)?

Lex Spoon: I believe it is acceptible to preload the images on the clients, but keep in mind that this means you will have to preload the images on all the clients, and that whenever the images change, you will have to update the clients. Anyway, converting a form to textual data is pretty easy in Squeak. As one starting point, consider that you can save a form to a file by using GIFReadWriter:
GIFReadWriter putForm: Display onFileNamed: 'test.gif'

(Note that Display is a perfectly valid Form.) You can then read in the file and send the data around. If you put the data into a file, you can then read it back:
form := GIFReadWriter formFromFileNamed: 'test.gif'

More explicitly, you cannot use pre-loading images as a mechanism to avoid passing images around via the network. So you can cache once you've pulled the images down (to make loading faster next time, for example), but you then have to check to verify that the image you've cached hasn't changed.


Lex, what do you mean "whenever the image changes"? Is there a requirement that the user be able to load in any image from disk? Or do you mean if the user decides to change his icon selection to another one (that's already predefined)? –Sebastian Becerra

I only meant, changes during the development of your program. Graphics must be developed just like code.... -Lex Spoon

That's ok, I meant that "whenever the image changes" means when any user changes his icon, your system needs to pull down the new icon and use it. For this milestone don't worry about dynamic updating (e.g. a user changes his icon repeatedly while a client is connected to your map server), but every time your client connects to the server it should check to see if it needs to download new images.


Are we allowed to reuse Lex's sample networking code in our own implementations?

Yes, but make sure your team does so because they think it's the appropriate design to use, not because it's the easiest.


For M2 does the user need to have an image or can we just have user objet draw something? how about the map?

Both the user icon and the map should be images.


In looking over the info file for this milestone, it says that 50% of the credit comes from having a working system. But the individual components of the working system only add up to 40%. Am I missing something???

Nope, we were just mathematically challenged when we assigned the original points. It's fixed now.


Would you please detail the requirements for SUnit testing M2? Thanks. -Jeff Y

Do we have to SUNIT test network components?

It's up to your group to decide exactly what you think the right pieces of functionality are to test (although feel free to consult with your TA to get feedback about whether or not you're on the right track). As a general rule of thumb, it's tough to unit test graphical interfaces, because they generally require action by the user. But you can unit test network interfaces in many cases; just connect to the local host (


How do you make multiple catch blocks in Smalltalk, or does it not matter?

Multiple catch blocks as in nested, or as in multiple catches for a single block? The former should be straightforward, though I haven't tried it. For the latter case, catch an exception higher in the hierarcy (like Exception) and test it at run time to see what type it is.


Are the server and client seperate or do they run on a single instance of Squeak, i.e. server on desktop and client on PDA, or both on PDA?

They must be able to run in separate Squeak images (and different machines), but you're welcome to write the code so that it also works on a single machine and in a single image.


How would one make threads go to sleep in Squeak like in Java?

See the OODesign lecture notes; slide 56. (Delay forSeconds: 1) wait.


It seems that Smalltalk supports multiple tasks via spawning new processes, not threading. Is this correct?

See Lex's comment below: Squeak processes are actually closer to threads.


Will there be a lecture on networking and threads in Smalltalk? A base would be nice.

I will be moving up that lecture, I just haven't decided exactly where to put it yet (discussing UI development is critical for the project too. In the short term, take a look at the networking powerpoint slides from previous 2340 offerings and look through OT chapter 4.


Could a TA please create a form to input questions?

Discover the "Edit" button. It's your friend.

Lex Spoon has helpfully put together a simple chat program as an example of networking in Squeak.


A Smalltalk "Process" is actually a thread, by today's terminology. It runs in the same address space. However, processes at the same priority do not preempty each other in Squeak; so don't fork something that uses 100% CPU. This said, you might want to try designs that use only one thread. If you use the usual threading approach of spawning a thread per connection and then trying to use locks to protect them from trampling on each other, you end up with a program that mostly works but has occasional weird crashes and hangs. It's hard to get all the locks correct, and it's hard to debug the problems when you have errors. But, it's up to you... Thread per Connection? -Lex Spoon

Link to this Page