[Newbies] User interfaces | getting started
Ron at USMedRec.com
Mon May 21 13:57:33 UTC 2007
Welcome to the list. I'm glad you have been reading about classes and
methods that should help. There is no console type application for Squeak.
The closest thing we have to a console app is the Transcript, but the
Transcript does not accept input. We also have inspectors, browsers and a
workspace with act much like the input side but they too are not really like
the console you may be expecting.
I agree with your path though, you want to get into the logic and flow of
the program without having to worry about GUI itself. Here is how you might
You create classes that represent your domain. For a contact list you might
create a contact and a contactBook.
Something simple like
Object subclass: #Contact
instanceVariableNames: 'name email phoneNumber'
Object subclass: #LittleBlackBook
You should create accessors and mutators for the instanceVariables on
Contact and LittleBlackBook.
LittleBlackBook >> initialize
contacts := OrderedCollection new.
Now what you need is a way to add contacts.
LittleBlackBook >> addContactNamed: aName email: anEmail phoneNumber:
"create a contact and add it to the list of contacts"
self contacts add: (Contact name: aName email: anEmail phoneNumber:
Contact class >> name: aName email: anEmail phoneNumber: aPhoneNumber
"Return to the sender a new instance of contact with this
Ok so very simply you can create instances of your book by starting from the
workspace and then using the inspectors for modifying your instance and
getting feedback. This feedback is different from a console but it does
give you a good feeling for objects.
>From a workspace you would do:
Now highlight that, right click -> inspect it.
What you get back is an inspector. This is an instance of your class
LittleBlackBook. Notice that you can click on the ivars and see their
contents. #contacts is currently empty.
On the inspector of LittelBlackBook you can now type: self. #self refers to
the instance itself. If you type self, highlight it and inspect it you get
the same instance back again. It's not a copy it's the same instance, what
ever you do to one will be reflected in the other since they are the same
The method we wrote can be called by using #self. Try this by typing this
in the inspector window of your instance of LittleBlackBook. (you can close
the second inspector).
self addContactNamed: 'Darren White' email: 'bobblebob at gmail.com'
You can just highlight it and do it. Now check out the contacts ivar. It
now has a contact in it. If you inspect the contact you will see that you
have a collection and if you inspect the first item in the collection you
will see that you have an instance of Contact, with your info in it.
It's not a console but there is nothing that a console can do that you can
not reproduce by adding new methods to your instance.
President / Principal Software Engineer
US Medical Record Specialists
From: Darren White
This is my first post here. I have been exploring the squeak environment and
smalltalk syntax for a few weeks now. Usually when learning a new
programming language I create a small programs such as a contacts list.
First I may do it with a console front end then play around with a GUI and
I have got to the stage with squeak where I want to do that but I can't see
how to proceed. For a console type program how do I proceed and for a GUI
program what is the main form/frame/window to hold the components. So the
main thing I'm stuck with is the user interface, I have read enough to know
how to create classes and their method bodies (though my code may be bad at
this stage :-) ).
Any advice would be most welcome, I can't wait to get stuck in!
More information about the Beginners