dry but why?

7
DRY : But Why? The warning signs, symptoms, and cure for repetitive html syndrome By Michael Knueppel

Upload: knuepwebdev

Post on 03-Aug-2015

186 views

Category:

Engineering


1 download

TRANSCRIPT

Page 1: Dry But Why?

DRY: But Why?

The warning signs, symptoms, and cure for repetitive html syndrome

By Michael Knueppel

Page 2: Dry But Why?

Monday morning<Developer’s Phone Rings…>

Developer: “Hello?”

Client: “I need you to make me a website”

Developer: “Sure!”

Client: “I want the site to have 100 web pages. I need it done by tomorrow morning”

Developer: “No problem. I type 120 wpm, so I can have it deployed by tonight”

Client: “Sounds good”

Page 3: Dry But Why?

The warning signEach web page needs to have the same header

The developer begins coding View #1

All 100 web pages have the same header

The developer is a fast typer, on a tight deadline, so the html block is copy/pasted 100 times

The app is completed in record time!

Page 4: Dry But Why?

The Symptom

<Client’s phone rings>

Client: “Hello?”

Developer: “All done”

Client: “Wow, the header looks great! But it has a spelling error. Can you fix it?”

<Developer is overcome with gloom>

Page 5: Dry But Why?

What went wrong?

The header was copy/pasted into each view

Even a minor change, such as correcting a spelling error or syntax error, requires editing many files

In this case, 100 files needed editing

Page 6: Dry But Why?

The cureExtract repetitive html into a partial template

To correct the spelling error, only one file needs to be edited (the partial template)

Partial templates provide the infrastructure for a low-maintenance app

Page 7: Dry But Why?

The implementation

For an example of how to implement a partial template, see my 2nd-to-last blog entry at

michaelknueppel.com