9. "Any fool can write code that
a computer can understand.
Good programmers write code that
humans can understand"
(Martin Fowler)
Friday, January 15, 2010
10. “Free software only matters
to those who can read”
(Robert M. Lefkowitz)
Friday, January 15, 2010
25. Waterfall
Jan Feb Mar Apr May Jun Jul
Cost of Maintenance Extreme Programming Explained: Embrace Change
Addison Wesley, 2000
Friday, January 15, 2010
26. XP
Jan Feb Mar Apr May Jun Jul
Cost of Maintenance Extreme Programming Explained: Embrace Change
Addison Wesley, 2000
Friday, January 15, 2010
27. code LESS
sleep MORE
http://www.flickr.com/photos/x180/503574487/
Friday, January 15, 2010
58. class Movie
def initialize(stars)
@stars = stars
end
def recommended?
((@stars > 5) ? 8 : 1) >= 8
end
end
Saturday, January 16, 2010
59. class Movie
def initialize(stars)
@stars = stars
end
def recommended?
rating = (@stars > 5) ? 8 : 1
rating >= 8
end
end
Saturday, January 16, 2010
60. class Movie
def initialize(stars)
@stars = stars
end
def recommended?
rating = (@stars > 5) ? 8 : 1
rating >= 8
end
end
Saturday, January 16, 2010
61. Replace Temp
With Query
Saturday, January 16, 2010
62. class Movie
def initialize(stars)
@stars = stars
end
def recommended?
rating = (@stars > 5) ? 8 : 1
rating >= 8
end
end
Saturday, January 16, 2010
63. class Movie
def initialize(stars)
@stars = stars
end
def recommended?
rating >= 8
end
def rating
(@stars > 5) ? 8 : 1
end
end
Saturday, January 16, 2010
64. OMG,
This is sooooo cooooool!
Saturday, January 16, 2010
65. class Movie
def recommended?
rating >= 8
end
def rating
(@stars > 5) ? 8 : 1
end
end
Saturday, January 16, 2010
66. class Movie
def recommended?
rating >= 8
end
def rating
more_than_five_stars? ? 8 : 1
end
def more_than_five_stars?
@stars > 5
end
end
Saturday, January 16, 2010
68. class Movie
def initialize...end
def recommended?
rating >= 8
end
def rating
more_than_five_stars? ? 8 : 1
end
def more_than_five_stars?
@stars > 5
end
end
Saturday, January 16, 2010
69. class Movie
def initialize...end
def recommended?
rating >= 8
end
def rating
@stars > 5 ? 8 : 1
end
end
Saturday, January 16, 2010
95. class MountainBike
def price
...
end
end
MountainBike.new(:type => :rigid, ...)
MountainBike.new(:type => :front_suspension, ...)
MountainBike.new(:type => :full_suspension, ...)
Saturday, January 16, 2010
96. def price
if @type_code == :rigid
(1 + @comission) * @base_price
end
if @type_code == :font_suspension
(1 + @comission) * @base_price +
@front_suspension_price
end
if @type_code == :full_suspension
(1 + @comission) * @base_price+
@front_suspension_price +
@rear_suspension_price
end
end
Saturday, January 16, 2010
97. def price
if @type_code == :rigid
(1 + @comission) * @base_price
end
if @type_code == :font_suspension
(1 + @comission) * @base_price +
@front_suspension_price
end
if @type_code == :full_suspension
(1 + @comission) * @base_price+
@front_suspension_price +
@rear_suspension_price
end
if @type_code == :ultra_suspension
...
end
end
Saturday, January 16, 2010
102. class RigidMountainBike
include MountainBike
end
class FrontSuspensionMountainBike
include MountainBike
end
class FullSuspensionMountainBike
include MountainBike
end
Saturday, January 16, 2010
104. class RigidMountainBike
include MountainBike
def price
(1 + @comission) * @base_price
end
end
Saturday, January 16, 2010
105. def price
if @type_code == :rigid
raise "should not be called"
end
if @type_code == :font_suspension
(1 + @comission) * @base_price +
@front_suspension_price
end
if @type_code == :full_suspension
(1 + @comission) * @base_price+
@front_suspension_price +
@rear_suspension_price
end
end
Saturday, January 16, 2010
106. class FrontSuspensionMountainBike
include MountainBike
def price
(1 + @comission) * @base_price +
@front_suspension_price
end
end
class FullSuspensionMountainBike
include MountainBike
def price
(1 + @comission) * @base_price +
@front_suspension_price +
@rear_suspension_price
end
end
Saturday, January 16, 2010
107. def price
if @type_code == :rigid
raise "should not be called"
end
if @type_code == :font_suspension
raise "should not be called"
end
if @type_code == :full_suspension
raise "should not be called"
end
end
Saturday, January 16, 2010
108. def price
if @type_code == :rigid
raise "should not be called"
end
if @type_code == :font_suspension
raise "should not be called"
end
if @type_code == :full_suspension
raise "should not be called"
end
end
Saturday, January 16, 2010
109. class RigidMountainBike
include MountainBike
end
class FrontSuspensionMountainBike
include MountainBike
end
class FullSuspensionMountainBike
include MountainBike
end
Saturday, January 16, 2010