============================================ Announcements: PS0 now available. Reading: Goldberg Chapters 1-3 ============================================ For today: -- review of the paradigm -- how the Smalltalk system hangs together browsers, workspaces, file lists, button pushes -- language conventions (syntax) ============================================ The basic OO paradigm: Objects respond to Messages according to their defined Methods. Objects are defined as members of Classes -- Classes are objects too! A Class defines -- instance variables -- one copy per instance -- class variables -- shared by all instances -- instance methods -- accessors, setters -- class methods -- instance creation -- initialization Objects are arranged in a hierarchy: Object -> Magnitude -> ArithmeticValue -> Number -> Integer -> SmallInteger Objects inherit all variables and methods from superclasses in the hierarchy. =========================================== Conventions: variableNamesWithoutPunctuation Account "class name" new "class method" NextAccountNumber "class variable" number "instance variable" balance "instance variable" number "instance method (accessor)" balance "instance method (accessor)" balance: "instance method (setter)" isOverdrawn "instance method" Variable types and naming conventions: GlobalVariable ClassVariable tempVariable messageParameter Symbols #fred #FrEd #fred = #fred #fReD = #FRED => false (symbols are case sensitive) Characters $c "is a printing character" "For non-printing characters, we ask the Character class to create one for us." Character esc. $ Comments and Strings "this is a comment" 'this is a string!' Numbers 3.14159 "numbers like you'd expect" Variables and the assignment operator "assignment operator and statement terminator" YYY := 'I am binding a global variable. Shame on me'. | x | "This is a temp variable. You usually " x := 3. " see this only in method definitions." x 3 << The above code evaluates to 3, but x is not declared to be global. >> Booleans "Our friend Mr. Boolean True!" 3 < 4. => the object true (instance of class Boolean) "Our friend Ms. Nil is here too, but she's not a Boolean" nil => the object nil (instance of UndefinedObject) Arrays #(1 'hi mom' #x).