Extracting wisdom from stupidity

Post on 10-Jan-2017

757 Views

Category:

Self Improvement

0 Downloads

Preview:

Click to see full reader

Transcript

THE STORY OF A RAFFLERExtracting wisdom from stupidity

About me

Ramon de la Fuente

Future500 B.V.

@f_u_e_n_t_e

SweetlakePHP

–Edward de Bono

“The purpose of the book has been to shift attention from the problems themselves to the

way the mind tackles them”

Stupidity

The words "stupid" and "stupidity" entered the English language in 1541. Since then, stupidity has taken place along with "fool," "idiot," "dumb," "moron," and related concepts as a pejorative appellation for human misdeeds, whether purposeful or accidental, due to absence of mental capacity.

Stupidity is a quality or state of being stupid, or an act or idea that exhibits properties of being stupid.

Code experiment

• 1. Write throw-away code

• 2. That performs some function

• 3. Wait, what??

Domcode Raffler Rules

• 1. Accept a filename as the first CLI argument.

• 2. The file will contain a \n delimited list of names

• 3. Echo a single random name from the list

–Johnny Appleseed

“Type a quote here.”

Code experiment

• 1. Write a raffler

• 2. Using every “array_” function in PHP

• 3. Exactly once

Insight

Sequential

Strategic

Logical Thinking Lateral Thinking

Logical Thinking Lateral Thinking

A

B

C

A

B

C

Y

Logical Thinking Lateral Thinking

A

B…Y

Z

A

Z

C

Y

Evolution

Evolution

Evolution

Evolution

–Matt Groening

The Six Stages of Debugging

1. That can't happen.

2. That doesn't happen on my machine.

3. That shouldn't happen.

4. Why is that happening?

5. Oh, I see

6. How did that ever work?

The Six Stages of Debugging

1. That can't happen.

2. That doesn't happen on my machine.

3. That shouldn't happen.

4. Why is that happening?

5. Oh, I see

6. How did that ever work?

• It forces you to plan before you code.

• It virtually eliminates coder's block.

• Writing Unit tests will improve the design.

Test Driven Development?

Scenario: Starting a game

Given the dictionary provides "coconut" When I start a game using the dictionary

Then there should be 11 guesses available And the revealed word should be "_______"

Test Driven Development?

Scenario: Starting a game

Given the dictionary provides "coconut" When I start a game using the dictionary

Then there should be 11 guesses available And the revealed word should be "_______"

Test Driven Development?

Scenario: Starting a game

Given the dictionary provides "coconut" When I start a game using the dictionary

Then there should be 11 guesses available And the revealed word should be "_______"

Test Driven Development?

Problem Solving

Problem Solving

Problem Solving

Better solution

Problem Solving

Barely working solution

Problem Solving

Better solution

Problem Solving

Barely working solution

Problem Solving

Problem Solving

✓ ✗✓

Problem Solving

Problem Solving

Problem Solving

Problem Solving

SINGLETONS

GOTO

SERVICE LOCATOR

Problem Solving

SINGLETONS

GOTO

SERVICE LOCATOR

Problem Solving

Problem Solving

Problem Solving

Problem Solving

Problem Solving

–Edward de Bono

“Excellent thinking is of no use if based on an incorrect assumption”

Problem Solving

You solve a Rubik’s Cube layer by layer,

by applying fixed sequences of moves,

leaving previously solved layers intact.

Problem Solving

You solve a Rubik’s Cube layer by layer,

by applying fixed sequences of moves,

leaving previously solved layers intact.

a programming problem

general patterns

Building a Raffler

Building a Raffler

Building a Raffler

Building a Raffler

• Separate by return value

• Add complexity score

• Group similar functions together

• Create composable blocks

Building a Raffler

Building a Raffler

Building a Raffler

/* returns original array */

.

Building a Raffler

Building a Raffler

Building a Raffler

Building a Raffler

Building a Raffler

Relevance?

Relevance?

“…do I use this interface, or not?”

– Senior developer

Relevance?

“…do I use this interface, or not?”

– Junior developer

Relevance?

“…I don’t understand how this can happen”

“…how could I make this happen??”

Further reading

“Experience is a museum for mistakes”

– Edward de Bono

Feedback on Joind.in: 16863@f_u_e_n_t_e

top related