advertisement

Code is read many mor times than written - short

50 %
50 %
advertisement
Information about Code is read many mor times than written - short
Technology

Published on February 24, 2014

Author: PragTob

Source: slideshare.net

Description

the slides from the 15 minute "Code is read many more times than written" talk I gave at the Rails Girls Berlin workshop on the 15th of February
advertisement

We write code

Isn't it more about reading?

Written once – read many times

„(…) when you program, you have to think about how someone will read your code, not just how a computer will interpret it.“ Kent Beck

Not about Architecture

Methods & Code

Extra effort

Save time

Your code base?

It's about joy!

Code is read many more times than written Tobias Pfeiffer @PragTob pragtob.info

Sources

Crazy?

Are comments a smell?

Outdated comments are the worst

The why not the what

Comments are an excuse of the code that it could not be clearer.

# do one thing … … … # do another thing … … … # do something more … …

Extract Methods

do_one_thing do_another_thing do_something_more

# context, outlet, times, time per step, state, data def pattern(c, o, t, l, s, d) # … end

Explanatory and meaningful names

def pattern(context, outlet, time, time_per_step, state, data) # … end

Try to keep it to 2 parameters

Short Methods (<= 8 LOC)

# allowed to drink? if customer.age > 18 say 'Okay' 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

if customer.age > 18 say 'Okay' 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

if customer.age > 18 say 'Okay' 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

if customer.age > 18 say 'Okay' 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

if allowed_to_drink_alcohol?(customer) serve_drink requested_drink, customer else propose_non_alcoholic_drink end

Nice code formatting

@left @top @width @height ||= ||= ||= ||= 0 0 1.0 0

double character: 'something weird', stateMask: CTRL | modifier, KeyCode: character.downcase.ord

80 character Width limit

80 character Width limit

80 character Width limit

80 character Width limit

80 character Width limit

Code bases detoriate

No broken windows

Magical time?

The Boyscout Rule

TDD

Know when to break the rules

If you still like your code from two years ago, then you are not learning fast enough.

Enjoy Coding! Tobias Pfeiffer @PragTob pragtob.info

Sources ● The Pragmatic Programmer ● Smalltalk Best Practice Patterns ● Clean Code ● Practical Object Oriented Design in Ruby

Photo Credit ● http://officeimg.vo.msecnd.net/en-us/images/MP900439313.jpg ● http://officeimg.vo.msecnd.net/en-us/images/MC900021328.wmf ● (CC BY-SA 2.0) – http://www.flickr.com/photos/83633410@N07/7658165122/ – ● http://www.flickr.com/photos/83633410@N07/7658272558/in/photostream/ – http://en.wikipedia.org/wiki/File:Kent_Beck_no_Workshop_Mapping_XP.jpg (CC BY-NC-ND 2.0) – http://www.flickr.com/photos/jasonlparks/4525188865/ – ● http://www.flickr.com/photos/12584908@N08/3293117576/ – ● http://www.flickr.com/photos/andih/86577529/ – http://www.flickr.com/photos/20714221@N04/2293045156/ http://www.flickr.com/photos/47833351@N02/5488791911/(CC BY-ND 2.0) (CC BY 2.0) – http://www.flickr.com/photos/25165196@N08/7725273678/ – ● http://www.flickr.com/photos/barry_b/76055201/ – http://www.flickr.com/photos/29254399@N08/3187186308/ (CC BY-NC-SA 2.0) – http://www.flickr.com/photos/antonkovalyov/5795281215/ – ● http://www.flickr.com/photos/dolescum/7380616658/ – http://www.flickr.com/photos/doug88888/2792209612/ (CC BY-NC 2.0) – http://www.flickr.com/photos/37996583811@N01/5757983532/ – http://www.flickr.com/photos/sevendead/5650065458/

Source pictures ● http://imagery.pragprog.com/products/59/tpp.jpg ● http://www.informit.com/ShowCover.aspx?isbn=9780132852111&type=f ● http://coding-in.net/blog/wp-content/uploads/clean_code.jpg ● http://www.informit.com/ShowCover.aspx?isbn=9780321721334&type=f ● http://mendicantuniversity.org/images/logo.png

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

Code is read many mor times than written - short ...

the slides from the 15 minute "Code is read many more times than written" talk I gave at the Rails Girls Berlin workshop on the 15th of February
Read more

Presentations by Tobias Pfeiffer // Speaker Deck

Talks by Tobias Pfeiffer. ... Code is read many mor times than written - short. Feb 15, ... Code is read many more times than written.
Read more

Code is read many mor times than written - short - Technology

the slides from the 15 minute "Code is read many more times than written" talk I gave at the Rails Girls Berlin workshop on the 15th of February
Read more

Morse code - Wikipedia

International Morse Code. Morse code has been in use for more than 160 ... in the form of Morse Code, though many VOR ... to read written ...
Read more

Mor | LinkedIn

View 18512 Mor posts ... Alon and I will travel to New York a few times this year to visit Bergdorf ... Code is read many mor times than written
Read more

How to Learn Morse Code: 6 Steps (with Pictures) - wikiHow

Use written Morse code to ... CW is up to 100 times more efficient than ... Thanks to all authors for creating a page that has been read 853,444 times.
Read more

Reading Data into SAS - University of California, Los Angeles

Welcome to the Institute for Digital Research and Education ... This page was written before 2005 and proc dbf is ... This code reads the Excel ...
Read more

Chapter 11 - Bankruptcy Basics | United States Courts

Background A case filed under chapter 11 of the United States Bankruptcy Code is ... The final installment must be paid not later than ... At times, a ...
Read more