Code, Comments, Concepts, Comprehension – Conclusion?
-
Upload
tobias-pfeiffer -
Category
Software
-
view
1.323 -
download
1
Transcript of Code, Comments, Concepts, Comprehension – Conclusion?
![Page 1: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/1.jpg)
We write code
![Page 2: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/2.jpg)
Isn't it moreabout reading?
![Page 3: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/3.jpg)
Written once -read many times
![Page 4: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/4.jpg)
(…) when you program, you have to think about how someone will read your code, not just how a
computer will interpret it.Kent Beck
![Page 5: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/5.jpg)
Any fool can write code that a computer can understand. Good programmers write code that
humans can understand.Martin Fowler
![Page 6: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/6.jpg)
Not about architecture
![Page 7: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/7.jpg)
Methods & Code
![Page 8: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/8.jpg)
Nurturing a code base
![Page 9: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/9.jpg)
Extra effort
![Page 10: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/10.jpg)
Save time!
![Page 11: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/11.jpg)
Your code base?
![Page 12: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/12.jpg)
![Page 13: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/13.jpg)
It's about joy!
![Page 14: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/14.jpg)
Code, Comments, Concepts, Comprehension – Conclusion?
Tobias Pfeiffer@PragTob
pragtob.info
![Page 15: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/15.jpg)
Crazy?
![Page 16: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/16.jpg)
Methods & Code
![Page 17: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/17.jpg)
![Page 18: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/18.jpg)
KeepItSimpleStupid
![Page 19: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/19.jpg)
Are comments a code smell?
![Page 20: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/20.jpg)
Comments are an excuse of the code that it could not be clearer.
![Page 21: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/21.jpg)
Outdated comments are the worst
![Page 22: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/22.jpg)
not the
WHYWHAT
![Page 23: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/23.jpg)
def paint_control(event) # some painting coderescue => 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
WHY comment
![Page 24: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/24.jpg)
Comments are the smell that tries to make other smells seem ok
![Page 25: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/25.jpg)
# do one thing............
# do another thing............
# do something more......
![Page 26: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/26.jpg)
# do one thing............
# do another thing............
# do something more......
![Page 27: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/27.jpg)
# do one thing............
# do another thing............
# do something more......
Cocepts
![Page 28: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/28.jpg)
Method too long
![Page 29: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/29.jpg)
Short Methods
![Page 30: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/30.jpg)
<= 8 LOC
![Page 31: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/31.jpg)
Extract Methods
![Page 32: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/32.jpg)
do_one_thingdo_another_thingdo_something_more
Concepts
![Page 34: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/34.jpg)
![Page 35: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/35.jpg)
"The more complex the code, the more comments it should have."
You should make the code less complex not add more comments.
Tiago Teixeira
![Page 36: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/36.jpg)
# context, outlet, times, time per step, state, datadef pattern(c, o, t, l, s, d) # ...end
![Page 37: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/37.jpg)
Incomprehensible names
![Page 38: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/38.jpg)
# context, outlet, times, time per step, state, datadef pattern(c, o, t, l, s, d) # ...end
![Page 39: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/39.jpg)
# context, outlet, times, time per step, state, datadef pattern(c, o, t, l, s, d) # ...end
![Page 40: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/40.jpg)
Explanatory names
![Page 41: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/41.jpg)
Naming is hard
![Page 42: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/42.jpg)
One Language
![Page 43: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/43.jpg)
def pattern(context, outlet, time, time_per_step, state, data) # ...end
![Page 44: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/44.jpg)
Argument order dependency
![Page 45: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/45.jpg)
Try to keep it to 2 parameters
![Page 46: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/46.jpg)
Example
![Page 47: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/47.jpg)
# allowed to drink?if customer.age >= 18 say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{['cola', 'mate'].sample}?"end
![Page 48: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/48.jpg)
# allowed to drink?if customer.age >= 18 say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{['cola', 'mate'].sample}?"end
![Page 49: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/49.jpg)
# allowed to drink?if customer.age >= 18 say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{['cola', 'mate'].sample}?"end
Magic „Numbers“
![Page 50: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/50.jpg)
NON_ALCOHOLIC_DRINKS = ['cola', 'mate']MIN_DRINKING_AGE = 18
![Page 51: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/51.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 52: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/52.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 53: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/53.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 54: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/54.jpg)
Query method
![Page 55: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/55.jpg)
Intention revealing method
![Page 56: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/56.jpg)
# ...text.color = red# ...
![Page 57: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/57.jpg)
# ...text.color = red# ...
![Page 58: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/58.jpg)
# ...highlight(text)# ...
![Page 59: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/59.jpg)
def highlight(text) text.color = redend
![Page 60: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/60.jpg)
def highlight(text) text.color = red text.underline = true update_highlightsend
![Page 61: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/61.jpg)
# ...text.color = redtext.underline = trueupdate_highlights# ...
![Page 62: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/62.jpg)
# ...highlight(text)# ...
![Page 63: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/63.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 64: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/64.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 65: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/65.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 66: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/66.jpg)
# allowed to drink?if customer.age >= MIN_DRINKING_AGE say 'Okay' drink = prepare_drink requested_drink say 'here you go' hand_drink_over drink, customerelse say 'I am sorry you are not legally allowed rather to drink here' say "Would you rather have a #{NON_ALCOHOLIC_DRINKS.sample}?"end
![Page 67: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/67.jpg)
if allowed_to_drink_alcohol?(customer) serve_drink requested_drink, customerelse propose_non_alcoholic_drinkend
![Page 68: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/68.jpg)
„If you have a good name for a method you don't need to look at
the body.“Martin Fowler
![Page 69: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/69.jpg)
„The easiest code to understand is the code you don't have to read at
all.“Tom Stuart (Berlin)
![Page 70: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/70.jpg)
def serve_alcoholic_drink(customer, requested_drink) if allowed_to_drink_alcohol?(customer) serve_drink requested_drink, customer else propose_non_alcoholic_drink endend
# more public methods
privatedef allowed_to_drink_alcohol?(customer)end
def serve_drink(requested_drink, customer)end
def propose_non_alcoholic_drinkend
Method Order
![Page 71: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/71.jpg)
def serve_alcoholic_drink(customer, requested_drink) if allowed_to_drink_alcohol?(customer) serve_drink requested_drink, customer else propose_non_alcoholic_drink endend
# more public methods
privatedef allowed_to_drink_alcohol?(customer)end
def serve_drink(requested_drink, customer)end
def propose_non_alcoholic_drinkend
![Page 72: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/72.jpg)
Method Order
def serve_alcoholic_drink(customer, requested_drink) if allowed_to_drink_alcohol?(customer) serve_drink requested_drink, customer else propose_non_alcoholic_drink endend
defp allowed_to_drink_alcohol?(customer)end
defp serve_drink(requested_drink, customer)end
defp propose_non_alcoholic_drinkend
# more public methods
![Page 73: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/73.jpg)
def serve_alcoholic_drink(customer, requested_drink) if allowed_to_drink_alcohol?(customer) serve_drink requested_drink, customer else propose_non_alcoholic_drink endend
defp allowed_to_drink_alcohol?(customer)end
defp serve_drink(requested_drink, customer)end
defp propose_non_alcoholic_drinkend
# more public methods
![Page 74: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/74.jpg)
prepare_drink requested_drinkprice = requested_drink.pricecheck = Check.newcheck.add_price pricesay 'That whill be ' + check.total
![Page 75: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/75.jpg)
prepare_drink requested_drinkprice = requested_drink.pricecheck = Check.newcheck.add_price pricesay 'That whill be ' + check.total
![Page 76: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/76.jpg)
prepare_drink requested_drinkprice = requested_drink.pricecheck = Check.newcheck.add_price pricesay 'That whill be ' + check.total
![Page 77: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/77.jpg)
Same level of abstraction in a method
![Page 78: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/78.jpg)
prepare_drink requested_drinkprepare_check requested_drink
![Page 79: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/79.jpg)
@left ||= 0@top ||= 0@width ||= 1.0@height ||= 0
Code Formatting
![Page 80: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/80.jpg)
double character: 'something weird', stateMask: CTRL | modifier, KeyCode: character.downcase.ord
Code Formatting
![Page 81: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/81.jpg)
80 character width limit
![Page 82: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/82.jpg)
80 character width limit
![Page 83: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/83.jpg)
80 character width limit
![Page 84: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/84.jpg)
80 character width limit
![Page 85: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/85.jpg)
80 character width limit
![Page 86: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/86.jpg)
Identify concepts
![Page 87: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/87.jpg)
Don'tRepeatYourself
![Page 88: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/88.jpg)
Don'tRepeatYourself(In Concepts)
![Page 89: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/89.jpg)
Virtues
![Page 90: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/90.jpg)
Simplicity
![Page 91: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/91.jpg)
The least powerful construct
![Page 92: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/92.jpg)
Explicit vs Implicit
![Page 93: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/93.jpg)
person = Person.new(attributes)do_something(person)insert_in_db(person)
Immutable Data
![Page 94: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/94.jpg)
person = Person.new(attributes)person = do_something(person)insert_in_db(person)
Immutable Data
![Page 95: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/95.jpg)
Transformation of data
![Page 96: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/96.jpg)
Reads like a book
![Page 97: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/97.jpg)
Nurturing a code base
![Page 98: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/98.jpg)
Code bases detoriate
![Page 99: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/99.jpg)
No broken windows!
![Page 100: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/100.jpg)
![Page 101: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/101.jpg)
![Page 102: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/102.jpg)
![Page 103: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/103.jpg)
![Page 104: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/104.jpg)
Magical time?
![Page 105: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/105.jpg)
The boyscout rule
![Page 106: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/106.jpg)
Opportunistic Refactoring
![Page 107: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/107.jpg)
Confident Tests
![Page 108: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/108.jpg)
80% Code Coverage
![Page 109: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/109.jpg)
20% never executed
![Page 110: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/110.jpg)
Code Review Culture
![Page 111: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/111.jpg)
Always the code, never the person
![Page 112: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/112.jpg)
Always the code, never the person
Say something positive
![Page 113: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/113.jpg)
Always the code, never the person
Say something positive
Use automated linters
![Page 114: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/114.jpg)
Always the code, never the person
Say something positive
Use automated lintersUse automated linters
Everyone reviews
![Page 115: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/115.jpg)
Always the code, never the person
Say something positive
Use automated lintersUse automated linters
Everyone reviews
Pairing Review
![Page 116: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/116.jpg)
Pair Programming
![Page 117: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/117.jpg)
The power of magic hats
![Page 118: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/118.jpg)
Reaping the benefits
![Page 119: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/119.jpg)
When to break the rules
![Page 120: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/120.jpg)
If you still like your code from two years ago,
then you are not learning fast enough.
![Page 121: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/121.jpg)
Enjoy writing readable code!
Tobias Pfeiffer@PragTob
pragtob.info
![Page 122: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/122.jpg)
RUG::B
benchmarking
Open Source
Testing
Ruby Implementations
![Page 123: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/123.jpg)
Sources
● The Pragmatic Programmer● Smalltalk Best Practice Patterns● Clean Code● Practical Object Oriented Design in Ruby
![Page 124: Code, Comments, Concepts, Comprehension – Conclusion?](https://reader034.fdocuments.in/reader034/viewer/2022052117/5a6ec6ec7f8b9a70728b6377/html5/thumbnails/124.jpg)
Photo Credit● http://officeimg.vo.msecnd.net/en-us/images/MP900439313.jpg
● http://officeimg.vo.msecnd.net/en-us/images/MC900021328.wmf
● http://www.osnews.com/story/19266/WTFs_m
● (CC BY-SA 2.0)
– http://www.flickr.com/photos/83633410@N07/7658272558/in/photostream/
– http://www.flickr.com/photos/83633410@N07/7658165122/
– https://www.flickr.com/photos/93425126@N00/313056379/
● (CC BY-NC-ND 2.0)
– http://www.flickr.com/photos/andih/86577529/
– http://www.flickr.com/photos/12584908@N08/3293117576/
– http://www.flickr.com/photos/jasonlparks/4525188865/
– http://www.flickr.com/photos/20714221@N04/2293045156/
– https://www.flickr.com/photos/eyewash/2603717864/
– https://www.flickr.com/photos/stevie_gill/3950697539/
– https://www.flickr.com/photos/randar/15787696685/
● http://www.flickr.com/photos/47833351@N02/5488791911/(CC BY-ND 2.0)
● (CC BY 2.0)
– http://www.flickr.com/photos/barry_b/76055201/
– http://www.flickr.com/photos/25165196@N08/7725273678/
– http://www.flickr.com/photos/29254399@N08/3187186308/
– https://www.flickr.com/photos/garryknight/5650367750/
– https://www.flickr.com/photos/alper/10742816123/
● (CC BY-NC-SA 2.0)
– http://www.flickr.com/photos/dolescum/7380616658/
– http://www.flickr.com/photos/antonkovalyov/5795281215/
– http://www.flickr.com/photos/doug88888/2792209612/
– https://www.flickr.com/photos/denverjeffrey/4392418334/
● (CC BY-NC 2.0)
– http://www.flickr.com/photos/37996583811@N01/5757983532/
– http://www.flickr.com/photos/sevendead/5650065458/
– https://www.flickr.com/photos/whitecatsg/3146092196/