Your SlideShare is downloading. ×
2008 Sccc Smalltalk
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×
Saving this for later? Get the SlideShare app to save on your phone or tablet. Read anywhere, anytime – even offline.
Text the download link to your phone
Standard text messaging rates apply

2008 Sccc Smalltalk

1,172

Published on

After a short introduction to object orientation, this lecture gives an overview of the Smalltalk programming language. …

After a short introduction to object orientation, this lecture gives an overview of the Smalltalk programming language.
This lecture was given on November 10, 2008, during the summer school on programming languages (http://pleiad.dcc.uchile.cl/pl2008/)

Published in: Education, Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,172
On Slideshare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
20
Comments
0
Likes
0
Embeds 0
No embeds

Report content
Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
No notes for slide

Transcript

  • 1. Object-oriented !quot;#$ programming in Smalltalk Alexandre Bergel RMoD team, INRIA, Lille, France alexandre@bergel.eu
  • 2. Goal of this lecture • Gain elementary notions of object orientation • Learn what is a pure object oriented language • Increase the programming language section on your CV
  • 3. Outline 1. Essence of class-based object orientation 2. Object oriented programming with Smalltalk 3. Smalltalk in Action
  • 4. Outline 1. Essence of class-based object orientation 2. Object oriented programming with Smalltalk 3. Smalltalk in Action
  • 5. Procedural programming color = data shape = behavior (Flatt 98)
  • 6. Procedural programming (Flatt 98)
  • 7. Expressing combination
  • 8. Example in C struct Point { struct Circle { const void * class; const void * class; int x, y; int x, y, rad; }; }; void draw (void * self) { void move (void * self) { switch(self[0]) { switch(self[0]) { case POINT_CLASS: ... case POINT_CLASS: ... case CIRCLE_CLASS: ... case CIRCLE_CLASS: ... } } } } !quot;#$
  • 9. Expressing extension
  • 10. Expressing extension
  • 11. Situation with some difficulties
  • 12. Object-oriented programming • Simula 67 addressed the combinational explosion of data and behavior • a class is an object factory • class = superclass + attributes + methods • object reactive to messages
  • 13. Object as programming entities a student printDescription() name=Bill courses={c1, c2}
  • 14. Object as programming entities ^ 'My name is ', Person name age gender description() Transcript show: printDescription() self description a student Student printDescription() name=Bill instance courses super description, courses={c1, c2} description() ' and I follows ', courses
  • 15. Object as programming entities ^ 'My name is ', Person name age gender description() Transcript show: printDescription() self description a student 1 Student printDescription() name=Bill instance courses super description, courses={c1, c2} description() ' and I follows ', courses
  • 16. Object as programming entities ^ 'My name is ', Person name age gender description() Transcript show: printDescription() self description a student 1 Student description() name=Bill instance courses super description, courses={c1, c2} description() ' and I follows ', courses 2
  • 17. Object as programming entities 3 ^ 'My name is ', Person name age gender description() Transcript show: printDescription() self description a student 1 Student super name=Bill instance courses super description, description() courses={c1, c2} description() ' and I follows ', courses 2
  • 18. Object as programming entities 3 ^ 'My name is ', Person name age gender description() Transcript show: printDescription() self description a student 1 Student super name=Bill instance courses super description, description() courses={c1, c2} description() ' and I follows ', courses 2
  • 19. Object-oriented programming Encapsulation Abstraction & Information Hiding Composition Nested Objects Distribution of Separation of concerns (e.g., HTML, CSS) Responsibility Message Passing Delegating responsibility Conceptual hierarchy, Inheritance polymorphism and reuse
  • 20. Outline 1. Essence of class-based object orientation 2. Object oriented programming with Smalltalk 3. Smalltalk in Action
  • 21. Smalltalk
  • 22. The origin of Smalltalk Alan Kay’s Dynabook project (1968) Alto — Xerox PARC (1973)
  • 23. Smalltalk today
  • 24. Smalltalk today
  • 25. Smalltalk today
  • 26. Smalltalk today
  • 27. Smalltalk today
  • 28. Squeak resources www.squeak.org www.seaside.st Downloads and links One-click image SqueakByExample.org Free download — Print-on-demand
  • 29. Getting started
  • 30. Everything is an object
  • 31. Everything happens by sending messages
  • 32. Running Squeak
  • 33. Do it, print it You can evaluate any expression anywhere in Smalltalk
  • 34. Standard development tools
  • 35. Debuggers, Inspectors, Explorers
  • 36. Syntax in a Nutshell
  • 37. Three kind of messages 5 factorial Unary messages Transcript cr Binary messages 3 + 4 Keyword messages 3 raisedTo: 10 modulo: 5 Transcript show: 'hello world'
  • 38. A typical method in the class Point Method name Argument Comment <= aPoint quot;Answer whether the receiver is neither below nor to the right of aPoint.quot; ^ x <= aPoint x and: [y <= aPoint y] Return Binary message Block Instance variable Keyword message (2@3) <= (5@6) true
  • 39. Statements and cascades Temporary variables Statement | p pen | p := 100@100. pen := Pen new. pen up. pen goto: p; down; goto: p+p Cascade
  • 40. Control structures Every control structure is realized by message sends 4 timesRepeat: [Beeper beep] max: aNumber ^ self < aNumber ifTrue: [aNumber] ifFalse: [self]
  • 41. Control structures Every control structure is realized by message sends 4 timesRepeat: [Beeper beep] Boolean ifTrue:ifFalse: max: aNumber True False ^ self < aNumber ifTrue:ifFalse: ifTrue:ifFalse: ifTrue: [aNumber] ifFalse: [self] ifTrue: t ifFalse: f ifTrue: t ifFalse: f ^ t value ^ f value
  • 42. Creating classes Send a message to a class (!) Number subclass: #Complex instanceVariableNames: 'real imaginary' classVariableNames: '' poolDictionaries: '' category: 'ComplexNumbers'
  • 43. Outline 1. Essence of class-based object orientation 2. Object oriented programming with Smalltalk 3. Smalltalk in Action

×