37. aString.substring(2, 5) aString copyFrom: 2 to: 5
ColorValue hue: a
new ColorValue(a, b, c)
saturation: b value: c
DateAndTime year: a day:
new DateAndTime(a, b, c)
b timeZone: c
Easier to document the semantic role
of arguments with keywords messages.
50. Dynamic binding
Postponing selection of an operation until
execution time
aCondition
ifTrue:[y:= 3]
ifFalse:[y:= #(1 2 3)].
y printOn: someStream.
Many printOn: methods,
compiler can’t preordain the choice.
58. Array
| life |
life := #(calvin hates suzie).
life at:2 put:#loves.
life. ⇒ #(#calvin #loves #suzie)
life first. ⇒ #calvin
life last. ⇒#suzie
life indexOf:#calvin. ⇒ 1
life indexOf:#asterix
ifAbsent:[Transcript show:’Je ne
connais pas’].
59. Set
s := Set new.
s add:1.
s add:2.
s add:2.
s. ⇒ a Set(1 2)
63. Collection enumeration
A collection contains a lot of elements.
Enumerate a collection is browsing the collection
and running a statement for each element:
do:, select:, reject:
collect:, inject:
65. do:
Evaluate the block for each element of the
collection.
total := 0.
a := #(1 2 3 4 5 6).
a do:[:unElement | total := total +
unElement]
66. select:
Evaluate the block for each element of the
collection and return a collectiof the items of the
same class containing elements whose evaluation
return true.
a := #(1 2 3 4 5 6).
a select:[:unElement| unElement even]
Return : #(2 4 6)
67. detect:
Evaluate the block for each element of the
collection and return the first element that
evaluate as the block value as true.
a := #(1 2 3 4 5 6).
a detect:[:unElement | unElement>3].
Return : 4.
78. Class inheritance
Rectangle
width
height
area
...
ColoredRectangle
color
...
79. a := Rectangle new.
a width:10.
a height:50.
a width. ⇒ 10
a height. ⇒ 50
a area. ⇒ 500
80. b := ColoredRectangle new.
b width:10.
b height:50.
b color: Color blue.
b width. ⇒ 10
b height. ⇒ 50
b color. ⇒ Color blue
b area. ⇒ 500
81. Rule 1
Everything is an object
Rule 2
Every object is an instance of one
class
Rule 3
Every class has a super-class
Rule 4
Everything happens by message
sending
82. Classes are also
objects !
1 class⇒ SmallInteger
20 factorial class ⇒
LargePositiveInteger
‘Hello’ class ⇒ ByteString
#(1 2 3) class ⇒ Array
83. Every class has a
superclass
Integer superclass ⇒ Integer
Number superclass ⇒ Magnitude
Magnitude superclass ⇒ Object
94. How many abstract
methods in the system ?
Object allSubclasses do:
[:aClass| aClass methodDict keys
select: [:aMethod |
(aClass>>aMethod)
isAbstract ]]
95. What is a dynamic
language ?
Dynamic typing: greater polymorphism
Metaprogramming (metaclasses):
allow language itself to be dynamically changed
allow hooks into object life cycle and method calls
Work with code as easily as data
Closures
Higher-order programming
96. Readability
Shorter code is easier to read and maintain and
refactor
Need balance between cryptic and expressive
97. square
^self*self
public int square(int x) {
return x * x;
}
98. button on: #mouseDown send:
#value to: [Object inform: 'You
clicked me'].
button.setOnClickListener(new
View.OnClickListener() {
public void onClick(View view) {
(Button) view.setText(""You Clicked
Me!")
}
});
101. In a nutshell
Pharo = language + IDE
Pure object-oriented programming language
(Smalltalk)
Dynamically language and trait-based
Open and flexible environment
Used Monticello for versionning (Metacello
planned for 1.1)
107. Polymorph UI
Polymorph provides support for selectable UI
themes in Morphic, extra widgets to support a
consistent look&fell, a framework for easily
creating UI in code.
Standard UI in Pharo
108.
109. Demo of Pharo
Simple examples
BlinkMorph example
Skins support
MultiMorph UI (UITheme examples)
110. Tests !
9179 unit tests includes in Pharo 1.0
9144 passes
20 expected failures
15 failures
0 errors
111. Everybody can help
Reporting bugs
Confirming bugs
Writing tests
Writing examples
Writing comments
Simple contributing fixes
Deep discussion...
112. Community Process
FIX/
ENHANCEMENT Discussed on
In PharoInbox or Discussed
Changesets on Mailing- BUG
list
Described
Described
BUG Tracker
Discussed on
Other
version
Integrated Rejected
114. Pharo Sprints
May 2008 Bern (Switzerland)
July 2009 Bern (Switzerland)
October 2009 Lille (France)
November 2009 Buenos Aires
(Argentina)
115. Thanks Hans Beck
Matthew Fulmer
Hilaire Fernandes
Julian Fitzell David J Pennell
Alexandre Bergel
Tudor Girba Joseph Pelrine
Cédric Beler
Sean Glazier Alain Plantec
Torsten Bergmann
Norbert Hartl Damien Pollet
Matthias Berth
Dale Henrichs Lukas Renggli
Ralph Boland
Reinout Heeck Jorge Ressia
Noury Bouraqadi
Eric Hochmeister Mike Roberts
Brian Brown
Keith Hodges Robert Rothwell
Gwenael Casaccio
Henrik Sperre Johansen David Rotlisberger
Damien Cassou
Pavel Krivanek Michael Rueger
Nicolas Cellier
Adrian Kuhn Bill Schwab
Gary Chambers
Adrian Lienhard Niko Schwarz
Miguel Coba
Andreas Leidig Igor Stasenko
Gabriel Cotelli
Mariano Martinez Peck Francois Stephany
Carlos Crosetti
Dave Mason Serge Stinckwich
Cyrille Delaunay
John McIntosh Mathieu Suen
Simon Denier
Johnaton Meichtry Lawrence Trutter
Marcus Denker
Eliot Miranda Andrew Tween
Ramiro Diaz Trepat
Hernan Morales Durand Martin von loewis
Stéphane Ducasse
Philipp Marshall Juan Vuletich
Morales Durand Hernan
Jannick Menanteau Steven Wirts
Stephan Eggermont
Yann Monclair Hernan Wilkinson
Luc Fabresse
Oscar Nierstrasz
116. Join Us!
Creating good energy, software quality,
learning and having fun
http://pharo-project.org
117. Cộng đồng Smalltalk Việt
Smalltalk-VN mailing-list :
http://lists.squeakfoundation.org/
mailman/listinfo/smalltalk-vn
Smalltalk flyer in vietnamese
EToys in vietnamese
118. Occam's razor: "entities should not be
multiplied beyond what is necessary" (entia
non sunt multiplicanda praeter necessitatem)
the simplest solution is usually the
correct one.
119. Thank you for your
attention.
Cám ơn sự quan
tâm của bạn.