Monday, February 01, 2016

Notes from Smalltalk Presentation by Dan

The real power is in the messaging. The message name represents what and the implementation is hidden behind the method.

Break complex problem down into:

As few parts as possible as independent as possible.
Easier to learn because fewer components.
Productive because the components are re-usable.

Simplicity and Generality

Analysis

Small number of independent parts

Synthesis

Easy to learn
Productive
Maintainable (Built with fewer components)

factorial
self <= 1
  ifTrue: []
 
 
self = 0 ifTrue: [^ 1].
self > 0 ifTrue: [^ self * (self - 1) factorial].
self error: 'Not valid for negative integers'


recFact
self < 0
     ifTrue : [^0]
     ifFalse: [
         self = 0
             ifTrue : [^1]
             ifFalse: [^self * (self -1) recFact]
              ]


Instead of :

loop do
 p 'This will print forever'
end

[ code ] repeat

Ruby Equivalent

(Block Object).repeat

Ignore knowledge about objects. Focus on messages.


Smalltalk