SlideShare a Scribd company logo
Object-oriented
                         !quot;#$




programming in
   Smalltalk
     Alexandre Bergel
    RMoD team, INRIA,
        Lille, France
   alexandre@bergel.eu
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
Outline



1. Essence of class-based object orientation
2. Object oriented programming with Smalltalk
3. Smalltalk in Action
Outline



1. Essence of class-based object orientation
2. Object oriented programming with Smalltalk
3. Smalltalk in Action
Procedural programming




                              color = data
                              shape = behavior


(Flatt 98)
Procedural programming




(Flatt 98)
Expressing combination
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;#$
Expressing extension
Expressing extension
Situation with some difficulties
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
Object as programming entities




                       a student

printDescription()      name=Bill
                     courses={c1, c2}
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
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
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
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
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
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
Outline



1. Essence of class-based object orientation
2. Object oriented programming with Smalltalk
3. Smalltalk in Action
Smalltalk
The origin of Smalltalk

          Alan Kay’s Dynabook project (1968)




                   Alto — Xerox PARC (1973)
Smalltalk today
Smalltalk today
Smalltalk today
Smalltalk today
Smalltalk today
Squeak resources


 www.squeak.org               www.seaside.st

Downloads and links           One-click image


        SqueakByExample.org
   Free download — Print-on-demand
Getting started
Everything is an object
Everything happens by sending
          messages
Running Squeak
Do it, print it




You can evaluate any
expression anywhere
    in Smalltalk
Standard development tools
Debuggers, Inspectors, Explorers
Syntax in a Nutshell
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'
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
Statements and cascades

   Temporary variables
                          Statement

        | p pen |
        p := 100@100.
        pen := Pen new.
        pen up.
        pen goto: p; down; goto: p+p

                         Cascade
Control structures
Every control structure is realized by message sends
            4 timesRepeat: [Beeper beep]




 max: aNumber
 
 ^ self < aNumber
 
 
 ifTrue: [aNumber]
 
 
 ifFalse: [self]
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
Creating classes
Send a message to a class (!)


        Number subclass: #Complex
        
 instanceVariableNames: 'real imaginary'
        
 classVariableNames: ''
        
 poolDictionaries: ''
        
 category: 'ComplexNumbers'
Outline



1. Essence of class-based object orientation
2. Object oriented programming with Smalltalk
3. Smalltalk in Action
2008 Sccc Smalltalk

More Related Content

What's hot

Evaluation of Exception Handling Metrics
Evaluation of Exception Handling MetricsEvaluation of Exception Handling Metrics
Evaluation of Exception Handling Metrics
IJASCSE
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
ITNet
 
Inheritance
InheritanceInheritance
Inheritance
Burhan Ahmed
 
M Gumbel - SCABIO: a framework for bioinformatics algorithms in Scala
M Gumbel - SCABIO: a framework for bioinformatics algorithms in ScalaM Gumbel - SCABIO: a framework for bioinformatics algorithms in Scala
M Gumbel - SCABIO: a framework for bioinformatics algorithms in Scala
Jan Aerts
 
JavaYDL11
JavaYDL11JavaYDL11
JavaYDL11
Terry Yoast
 
Inheritance (1)
Inheritance (1)Inheritance (1)
Inheritance (1)
sanya6900
 
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsBca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objects
Rai University
 
JAVA CONCEPTS
JAVA CONCEPTS JAVA CONCEPTS
JAVA CONCEPTS
Shivam Singh
 
Introduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutletIntroduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutlet
Oldingz
 

What's hot (9)

Evaluation of Exception Handling Metrics
Evaluation of Exception Handling MetricsEvaluation of Exception Handling Metrics
Evaluation of Exception Handling Metrics
 
Ch.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objectsCh.1 oop introduction, classes and objects
Ch.1 oop introduction, classes and objects
 
Inheritance
InheritanceInheritance
Inheritance
 
M Gumbel - SCABIO: a framework for bioinformatics algorithms in Scala
M Gumbel - SCABIO: a framework for bioinformatics algorithms in ScalaM Gumbel - SCABIO: a framework for bioinformatics algorithms in Scala
M Gumbel - SCABIO: a framework for bioinformatics algorithms in Scala
 
JavaYDL11
JavaYDL11JavaYDL11
JavaYDL11
 
Inheritance (1)
Inheritance (1)Inheritance (1)
Inheritance (1)
 
Bca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objectsBca 2nd sem u-2 classes & objects
Bca 2nd sem u-2 classes & objects
 
JAVA CONCEPTS
JAVA CONCEPTS JAVA CONCEPTS
JAVA CONCEPTS
 
Introduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutletIntroduction to classes the concept of a class/tutorialoutlet
Introduction to classes the concept of a class/tutorialoutlet
 

Viewers also liked

Pharo: Objects at your Fingertips
Pharo: Objects at your FingertipsPharo: Objects at your Fingertips
Pharo: Objects at your Fingertips
Marcus Denker
 
Pharo devnology20150401
Pharo devnology20150401Pharo devnology20150401
Pharo devnology20150401
Stephan Eggermont
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
Marcus Denker
 
The Pharo Programming Language
The Pharo Programming LanguageThe Pharo Programming Language
The Pharo Programming Language
bergel
 
Squeak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC SmalltalkSqueak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC Smalltalk
SeanDeNigris
 
Pharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntaxPharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntax
Pharo
 
Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013
Pharo
 
Pharo Roadmap
Pharo RoadmapPharo Roadmap
Pharo Roadmap
ESUG
 
You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!
ESUG
 
Pharo Hands-on: 05 object model
Pharo Hands-on: 05 object modelPharo Hands-on: 05 object model
Pharo Hands-on: 05 object model
Pharo
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scala
pt114
 
Stoop 432-singleton
Stoop 432-singletonStoop 432-singleton
Stoop 432-singleton
The World of Smalltalk
 

Viewers also liked (12)

Pharo: Objects at your Fingertips
Pharo: Objects at your FingertipsPharo: Objects at your Fingertips
Pharo: Objects at your Fingertips
 
Pharo devnology20150401
Pharo devnology20150401Pharo devnology20150401
Pharo devnology20150401
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
The Pharo Programming Language
The Pharo Programming LanguageThe Pharo Programming Language
The Pharo Programming Language
 
Squeak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC SmalltalkSqueak & Pharo @ NYC Smalltalk
Squeak & Pharo @ NYC Smalltalk
 
Pharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntaxPharo Hands-On: 02 syntax
Pharo Hands-On: 02 syntax
 
Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013Pharo tutorial at ECOOP 2013
Pharo tutorial at ECOOP 2013
 
Pharo Roadmap
Pharo RoadmapPharo Roadmap
Pharo Roadmap
 
You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!You Can’t Do That With Smalltalk!
You Can’t Do That With Smalltalk!
 
Pharo Hands-on: 05 object model
Pharo Hands-on: 05 object modelPharo Hands-on: 05 object model
Pharo Hands-on: 05 object model
 
Haskell vs. F# vs. Scala
Haskell vs. F# vs. ScalaHaskell vs. F# vs. Scala
Haskell vs. F# vs. Scala
 
Stoop 432-singleton
Stoop 432-singletonStoop 432-singleton
Stoop 432-singleton
 

More from bergel

Building Neural Network Through Neuroevolution
Building Neural Network Through NeuroevolutionBuilding Neural Network Through Neuroevolution
Building Neural Network Through Neuroevolution
bergel
 
Roassal presentation
Roassal presentationRoassal presentation
Roassal presentation
bergel
 
2011 famoosr
2011 famoosr2011 famoosr
2011 famoosr
bergel
 
2011 ecoop
2011 ecoop2011 ecoop
2011 ecoop
bergel
 
Test beautycleanness
Test beautycleannessTest beautycleanness
Test beautycleanness
bergel
 
Multi dimensional profiling
Multi dimensional profilingMulti dimensional profiling
Multi dimensional profiling
bergel
 
Profiling blueprints
Profiling blueprintsProfiling blueprints
Profiling blueprints
bergel
 
2008 Sccc Inheritance
2008 Sccc Inheritance2008 Sccc Inheritance
2008 Sccc Inheritance
bergel
 
Presentation of Traits
Presentation of TraitsPresentation of Traits
Presentation of Traits
bergel
 
2006 Seaside
2006 Seaside2006 Seaside
2006 Seaside
bergel
 
2006 Small Scheme
2006 Small Scheme2006 Small Scheme
2006 Small Scheme
bergel
 
2004 Esug Prototalk
2004 Esug Prototalk2004 Esug Prototalk
2004 Esug Prototalk
bergel
 
2005 Oopsla Classboxj
2005 Oopsla Classboxj2005 Oopsla Classboxj
2005 Oopsla Classboxj
bergel
 
2006 Esug Omnibrowser
2006 Esug Omnibrowser2006 Esug Omnibrowser
2006 Esug Omnibrowser
bergel
 

More from bergel (14)

Building Neural Network Through Neuroevolution
Building Neural Network Through NeuroevolutionBuilding Neural Network Through Neuroevolution
Building Neural Network Through Neuroevolution
 
Roassal presentation
Roassal presentationRoassal presentation
Roassal presentation
 
2011 famoosr
2011 famoosr2011 famoosr
2011 famoosr
 
2011 ecoop
2011 ecoop2011 ecoop
2011 ecoop
 
Test beautycleanness
Test beautycleannessTest beautycleanness
Test beautycleanness
 
Multi dimensional profiling
Multi dimensional profilingMulti dimensional profiling
Multi dimensional profiling
 
Profiling blueprints
Profiling blueprintsProfiling blueprints
Profiling blueprints
 
2008 Sccc Inheritance
2008 Sccc Inheritance2008 Sccc Inheritance
2008 Sccc Inheritance
 
Presentation of Traits
Presentation of TraitsPresentation of Traits
Presentation of Traits
 
2006 Seaside
2006 Seaside2006 Seaside
2006 Seaside
 
2006 Small Scheme
2006 Small Scheme2006 Small Scheme
2006 Small Scheme
 
2004 Esug Prototalk
2004 Esug Prototalk2004 Esug Prototalk
2004 Esug Prototalk
 
2005 Oopsla Classboxj
2005 Oopsla Classboxj2005 Oopsla Classboxj
2005 Oopsla Classboxj
 
2006 Esug Omnibrowser
2006 Esug Omnibrowser2006 Esug Omnibrowser
2006 Esug Omnibrowser
 

Recently uploaded

Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
TechSoup
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
Jyoti Chand
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
shreyassri1208
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
deepaannamalai16
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
Kalna College
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
khuleseema60
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
nitinpv4ai
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
Celine George
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
deepaannamalai16
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
nitinpv4ai
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Henry Hollis
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
haiqairshad
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
Celine George
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
zuzanka
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapitolTechU
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
RamseyBerglund
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Kalna College
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
Nguyen Thanh Tu Collection
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
danielkiash986
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
sonukumargpnirsadhan
 

Recently uploaded (20)

Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
Elevate Your Nonprofit's Online Presence_ A Guide to Effective SEO Strategies...
 
Wound healing PPT
Wound healing PPTWound healing PPT
Wound healing PPT
 
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGHKHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
KHUSWANT SINGH.pptx ALL YOU NEED TO KNOW ABOUT KHUSHWANT SINGH
 
Standardized tool for Intelligence test.
Standardized tool for Intelligence test.Standardized tool for Intelligence test.
Standardized tool for Intelligence test.
 
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx78 Microsoft-Publisher - Sirin Sultana Bora.pptx
78 Microsoft-Publisher - Sirin Sultana Bora.pptx
 
MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025MDP on air pollution of class 8 year 2024-2025
MDP on air pollution of class 8 year 2024-2025
 
Bonku-Babus-Friend by Sathyajith Ray (9)
Bonku-Babus-Friend by Sathyajith Ray  (9)Bonku-Babus-Friend by Sathyajith Ray  (9)
Bonku-Babus-Friend by Sathyajith Ray (9)
 
How to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in useHow to Fix [Errno 98] address already in use
How to Fix [Errno 98] address already in use
 
HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.HYPERTENSION - SLIDE SHARE PRESENTATION.
HYPERTENSION - SLIDE SHARE PRESENTATION.
 
Skimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S EliotSkimbleshanks-The-Railway-Cat by T S Eliot
Skimbleshanks-The-Railway-Cat by T S Eliot
 
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.pptLevel 3 NCEA - NZ: A  Nation In the Making 1872 - 1900 SML.ppt
Level 3 NCEA - NZ: A Nation In the Making 1872 - 1900 SML.ppt
 
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skillsspot a liar (Haiqa 146).pptx Technical writhing and presentation skills
spot a liar (Haiqa 146).pptx Technical writhing and presentation skills
 
How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17How to Download & Install Module From the Odoo App Store in Odoo 17
How to Download & Install Module From the Odoo App Store in Odoo 17
 
SWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptxSWOT analysis in the project Keeping the Memory @live.pptx
SWOT analysis in the project Keeping the Memory @live.pptx
 
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptxCapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
CapTechTalks Webinar Slides June 2024 Donovan Wright.pptx
 
Electric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger HuntElectric Fetus - Record Store Scavenger Hunt
Electric Fetus - Record Store Scavenger Hunt
 
Contiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptxContiguity Of Various Message Forms - Rupam Chandra.pptx
Contiguity Of Various Message Forms - Rupam Chandra.pptx
 
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
CHUYÊN ĐỀ ÔN TẬP VÀ PHÁT TRIỂN CÂU HỎI TRONG ĐỀ MINH HỌA THI TỐT NGHIỆP THPT ...
 
Pharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brubPharmaceutics Pharmaceuticals best of brub
Pharmaceutics Pharmaceuticals best of brub
 
BPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end examBPSC-105 important questions for june term end exam
BPSC-105 important questions for june term end exam
 

2008 Sccc Smalltalk

  • 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)
  • 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;#$
  • 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
  • 22. The origin of Smalltalk Alan Kay’s Dynabook project (1968) Alto — Xerox PARC (1973)
  • 28. Squeak resources www.squeak.org www.seaside.st Downloads and links One-click image SqueakByExample.org Free download — Print-on-demand
  • 31. Everything happens by sending messages
  • 33. Do it, print it You can evaluate any expression anywhere in Smalltalk
  • 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