SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy.
SlideShare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our Privacy Policy and User Agreement for details.
Successfully reported this slideshow.
Activate your 14 day free trial to unlock unlimited reading.
What do software engineers do all day long? Write code? Of course! But what about reading code, about understanding what’s happening? Aren’t we doing that even more? I believe we do. Because of that code should be as readable as possible! But what does that even mean? How do we achieve readable code? This talk will introduce you to coding principles and techniques that will help you write more readable code, be more productive and have more fun!
What do software engineers do all day long? Write code? Of course! But what about reading code, about understanding what’s happening? Aren’t we doing that even more? I believe we do. Because of that code should be as readable as possible! But what does that even mean? How do we achieve readable code? This talk will introduce you to coding principles and techniques that will help you write more readable code, be more productive and have more fun!
21.
def paint_control(event)
# some painting code
rescue => e
# Really important to rescue here.
Failures that escape this method
# cause odd-ball hangs with no
backtraces. See #559 for an example.
#
puts "SWALLOWED PAINT EXCEPTION ON
#{@obj} - go take care of it: " + e.to_s
puts 'Unfortunately we have to swallow
it because it causes odd failures :('
end
22.
Also known as the smell that
tries to make other smells
seem ok
23.
# do one thing
...
...
...
...
...
# do another thing
...
...
...
...
# do something more
...
...
24.
# do one thing
...
...
...
...
...
# do another thing
...
...
...
...
# do something more
...
...
25.
# do one thing
...
...
...
...
...
# do another thing
...
...
...
...
# do something more
...
...
Cocepts
41.
# allowed to drink?
if customer.age >= 18
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{['cola', 'mate'].sample}?"
end
42.
# allowed to drink?
if customer.age >= 18
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{['cola', 'mate'].sample}?"
end
45.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
46.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
47.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
57.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
58.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
59.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
60.
# allowed to drink?
if customer.age >= MIN_DRINKING_AGE
say 'Okay'
drink = prepare_drink requested_drink
say 'here you go'
hand_drink_over drink, customer
else
say 'I am sorry you are not legally
allowed rather to drink here'
say "Would you rather have a
#{NON_ALCOHOLIC_DRINKS.sample}?"
end
61.
if allowed_to_drink_alcohol?(customer)
serve_drink requested_drink,
customer
else
propose_non_alcoholic_drink
end
62.
„If you have a good name for
a method you don't need to
look at the body.“
Martin Fowler
63.
„The easiest code to
understand is the code you
don't have to read at all.“
Tom Stuart (Berlin)
64.
prepare_drink requested_drink
price = requested_drink.price
check = Check.new
check.add_price price
say 'That whill be ' + check.total
65.
prepare_drink requested_drink
price = requested_drink.price
check = Check.new
check.add_price price
say 'That whill be ' + check.total
66.
prepare_drink requested_drink
price = requested_drink.price
check = Check.new
check.add_price price
say 'That whill be ' + check.total