A Little Journey in the PharoObject ModelStéphane Ducassehttp://www.pharo.org
A pure and minimal object modelLess is more!
No constructors, no static methods, no operatorsNo type declaration, no primitive types,No interfaces, no need for factory...
Everything is an object
Objects are instances ofClasses
(10@200)Objects are instances ofClasses
(10@200) classObjects are instances ofClasses
(10@200) classPointObjects are instances ofClasses
Classes are objects too
Point selectorsClasses are objects too
Point selectors> an IdentitySet(#eightNeighbors #+ #isZero#sortsBefore: #degrees #printOn: #sideOf:#fourNeighbors #hash #r...
Point instVarNamesClasses are objects too
Point instVarNames>#(x y)Classes are objects too
Methods are public
Methods are all late-bound
Instance variables areprotected
Single Inheritance
Object subclass: #Point	 instanceVariableNames: x y	 classVariableNames: 	 category: Graphics-PrimitivesSingle Inheritance
Messages + Objects
ObjectNodeaccept:namesendt:node1msgThe key to everything
Classes are objects too
Point classClasses are objects too
Point class>Point classClasses are objects too
Point class>Point class“Point class” is an anonymous class with only oneinstance: PointClasses are objects too
Class Parallel InheritanceNode classnewwithName: aStringinstance ofNodenameaccept: aPacketsend: aPacketWorkstationoriginat...
Lookup and Class Methods
About the Buttons
Class methods are plain latebound methods as anymethods!
Package extensionsA method can be defined in a class thatis packaged in another package!Powerful to build layers
Defined in the Dice packageInteger>>D20^ self D: 20Integer>>D: anInteger| h |h := DiceHandle newself timesRepeat:[h addDice...
SummaryEverything is an objectSingle inheritance, public methods,protected attributesOne single modelClasses are simply ob...
Upcoming SlideShare
Loading in...5
×

2013 lecture-02-model

242

Published on

An introduction of the Pharo execution model.
Pharo is a new dynamically typed language. It is inspired from Smalltalk and it is
elegant, simple and powerful. http://www.pharo.org

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

  • Be the first to like this

No Downloads
Views
Total Views
242
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

2013 lecture-02-model

  1. 1. A Little Journey in the PharoObject ModelStéphane Ducassehttp://www.pharo.org
  2. 2. A pure and minimal object modelLess is more!
  3. 3. No constructors, no static methods, no operatorsNo type declaration, no primitive types,No interfaces, no need for factoryNo packages/private/protected modifiersNo parametrized typesNo boxing/unboxingStill powerful
  4. 4. Everything is an object
  5. 5. Objects are instances ofClasses
  6. 6. (10@200)Objects are instances ofClasses
  7. 7. (10@200) classObjects are instances ofClasses
  8. 8. (10@200) classPointObjects are instances ofClasses
  9. 9. Classes are objects too
  10. 10. Point selectorsClasses are objects too
  11. 11. Point selectors> an IdentitySet(#eightNeighbors #+ #isZero#sortsBefore: #degrees #printOn: #sideOf:#fourNeighbors #hash #roundUpTo: #min: #min:max:#max #adaptToCollection:andSend: #quadrantOf:#crossProduct: #= #nearestPointOnLineFrom:to:#bitShiftPoint: #* #guarded #insideTriangle:with:with:#grid: #truncateTo: #y #setR:degrees: #normalClasses are objects too
  12. 12. Point instVarNamesClasses are objects too
  13. 13. Point instVarNames>#(x y)Classes are objects too
  14. 14. Methods are public
  15. 15. Methods are all late-bound
  16. 16. Instance variables areprotected
  17. 17. Single Inheritance
  18. 18. Object subclass: #Point instanceVariableNames: x y classVariableNames: category: Graphics-PrimitivesSingle Inheritance
  19. 19. Messages + Objects
  20. 20. ObjectNodeaccept:namesendt:node1msgThe key to everything
  21. 21. Classes are objects too
  22. 22. Point classClasses are objects too
  23. 23. Point class>Point classClasses are objects too
  24. 24. Point class>Point class“Point class” is an anonymous class with only oneinstance: PointClasses are objects too
  25. 25. Class Parallel InheritanceNode classnewwithName: aStringinstance ofNodenameaccept: aPacketsend: aPacketWorkstationoriginate: aPacketaccept: aPacketaWorkstation (BigMac)Workstationclassinstance of
  26. 26. Lookup and Class Methods
  27. 27. About the Buttons
  28. 28. Class methods are plain latebound methods as anymethods!
  29. 29. Package extensionsA method can be defined in a class thatis packaged in another package!Powerful to build layers
  30. 30. Defined in the Dice packageInteger>>D20^ self D: 20Integer>>D: anInteger| h |h := DiceHandle newself timesRepeat:[h addDice: (Dice faces: anInteger)].^ h2 D20: two dice of 20 faces
  31. 31. SummaryEverything is an objectSingle inheritance, public methods,protected attributesOne single modelClasses are simply objects tooA class is instance of another classOne unique method lookup, look in theclass of the receiver
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×