From Mountain West Ruby Conference 2014.
A good design communicates the intended use of an object. In the physical world, this communication is accomplished by “affordances”, as discussed by Donald Norman in “The Psychology of Everyday Things”.
Programming languages also have affordances, and they influence the kinds of solutions we develop. The more languages we know, the more we “expand our design space” so that we can come up with better solutions to the problems we face every day.
18. 3/20/2014 Affordances
http://localhost:9090/onepage 18/67
class Point
def self.xy(x, y)
new(x, y)
end
def self.polar(r, theta)
xy(r * Math.cos(theta),
r * Math.sin(theta))
end
private_class_method :new
# ... rest same as before
end
Point.xy(3, 4)
Point.polar(5, 0.927295)