Our Philosophy Write readable code Care about the detail Make it - - PowerPoint PPT Presentation

our philosophy
SMART_READER_LITE
LIVE PREVIEW

Our Philosophy Write readable code Care about the detail Make it - - PowerPoint PPT Presentation

Programming in the Small Ivan Moore & Mike Hill Our Philosophy Write readable code Care about the detail Make it routine Its important Explanation by Example Mini-series of programming episodes Interactive demo in


slide-1
SLIDE 1

Programming in the Small

Ivan Moore & Mike Hill

slide-2
SLIDE 2

Our Philosophy

  • Write readable code
  • Care about the detail
  • Make it routine
  • It’s important
slide-3
SLIDE 3

Explanation by Example

  • Mini-series of programming episodes
  • Interactive demo in Java
slide-4
SLIDE 4
  • 1. “Where to Start?”
slide-5
SLIDE 5
  • Pair up
  • Look at the 1st example, Checker.java
  • Read through the code, and think about what you’d like to

do to it...

Examples can be downloaded from http://www.exdriven.co.uk/pits/

slide-6
SLIDE 6

Thoughts?

slide-7
SLIDE 7

PITS Lessons (1)

  • Start with small improvements:
  • Convert comments into code
  • Fix the formatting
  • Remove unnecessary code (use the IDE

to warn you about this)

slide-8
SLIDE 8
  • 2. “When to Stop!”
slide-9
SLIDE 9
  • Pair up
  • Look at the 2nd example, Args.java
  • If you owned this code, what would you do to it?

Examples can be downloaded from http://www.exdriven.co.uk/pits/

slide-10
SLIDE 10

Thoughts?

slide-11
SLIDE 11

PITS Lessons (2)

  • Attempt to remove all duplication - even if

small

  • Multiple exits can improve readability

(breaking structured programming rules)

  • Make declarations as local as possible
slide-12
SLIDE 12
  • 3. “Don’t stop now!”
slide-13
SLIDE 13
  • Pair up
  • Look at the 3rd example, BusinessDay.java
  • Does this look ok to you?

Examples can be downloaded from http://www.exdriven.co.uk/pits/

slide-14
SLIDE 14

Thoughts?

slide-15
SLIDE 15

PITS Lessons (3)

  • Simplify your conditionals
  • Removing duplication sometimes requires

the creation of tiny function/policy objects

slide-16
SLIDE 16

Extra PITS

  • Be discreet - keep your privates private
  • Avoid statics and NoJos in favour of objects

with behaviour

  • Hide your primitives inside domain objects
slide-17
SLIDE 17

Recap...

slide-18
SLIDE 18

Recap...

★Don’t write pointless comments

slide-19
SLIDE 19

Recap...

★Don’t write pointless comments ★Fix your formatting - show that you care

slide-20
SLIDE 20

Recap...

★Don’t write pointless comments ★Fix your formatting - show that you care ★Turn up your warnings and delete more code

slide-21
SLIDE 21

Recap...

★Don’t write pointless comments ★Fix your formatting - show that you care ★Turn up your warnings and delete more code ★Remove the little bits of duplication

slide-22
SLIDE 22

Recap...

★Don’t write pointless comments ★Fix your formatting - show that you care ★Turn up your warnings and delete more code ★Remove the little bits of duplication ★Break stupid structured programming rules

slide-23
SLIDE 23

Recap...

★Don’t write pointless comments ★Fix your formatting - show that you care ★Turn up your warnings and delete more code ★Remove the little bits of duplication ★Break stupid structured programming rules ★Keep your scoping local and private

slide-24
SLIDE 24

Recap...

★Don’t write pointless comments ★Fix your formatting - show that you care ★Turn up your warnings and delete more code ★Remove the little bits of duplication ★Break stupid structured programming rules ★Keep your scoping local and private ★Write domain objects with behaviour

slide-25
SLIDE 25

It’s the PITS!

Ivan’s blog :: http://puttingtheteaintoteam.blogspot.com/ PITS articles :: http://ivan.truemesh.com/archives/cat_programming_in_the_small.htm Contact us :: mike@exdriven.co.uk and ivan@teamoptimization.com