Error(s) Free Programming

108
Error(s) Free Programming Dave Cross @davorg / @perlhacks [email protected]

Transcript of Error(s) Free Programming

Page 1: Error(s) Free Programming

Error(s) Free Programming

Dave Cross@davorg / @[email protected]

Page 2: Error(s) Free Programming

We alldo it

Page 3: Error(s) Free Programming

“There was 1 error(s)”

Page 4: Error(s) Free Programming

“You have 3 message(s) waiting”

Page 5: Error(s) Free Programming

Good enough

Page 6: Error(s) Free Programming

Is it?

Page 7: Error(s) Free Programming

Bad English

Page 8: Error(s) Free Programming

txtspk

Page 9: Error(s) Free Programming
Page 10: Error(s) Free Programming

“Good enough” isn't

good enough

Page 11: Error(s) Free Programming

Why dowe do it?

Page 12: Error(s) Free Programming

Lazy

Page 13: Error(s) Free Programming

if ($count == 1) { $word = 'error';} else { $word = 'errors';}

Page 14: Error(s) Free Programming

$word = 'error';$word .= 's' if $count != 1;

Page 15: Error(s) Free Programming

Tedious

Page 16: Error(s) Free Programming

There is a solution

Page 17: Error(s) Free Programming

Lingua::EN::Inflexion

Page 18: Error(s) Free Programming
Page 19: Error(s) Free Programming

Inflects words for

you

Page 20: Error(s) Free Programming

Nouns

Page 21: Error(s) Free Programming

Nouns(Things)

Page 22: Error(s) Free Programming

Verbs

Page 23: Error(s) Free Programming

Verbs(Actions)

Page 24: Error(s) Free Programming

Adjectives

Page 25: Error(s) Free Programming

Adjectives(Descriptions)

Page 26: Error(s) Free Programming

$word = noun('error');say $word->singular; # errorsay $word->plural; # errors

Page 27: Error(s) Free Programming

$word = verb('was');say $word->singular; # wassay $word->plural; # were

Page 28: Error(s) Free Programming

$word = adj('our');say $word->singular; # mysay $word->plural; # our

Page 29: Error(s) Free Programming

Knows grammar

Page 30: Error(s) Free Programming

noun("uncle")->indef_article(); # "an"noun("union")->indef_article(); # "a"noun("house")->indef_article(); # "a"noun("hours")->indef_article(); # "an"

Page 31: Error(s) Free Programming

as_regex()

Page 32: Error(s) Free Programming

$text =~ noun('cow')->as_regex

Page 33: Error(s) Free Programming

$text =~ noun('cow')

Page 34: Error(s) Free Programming

say noun('cow')->as_regex# (?^i:kine|cows|cow)

Page 35: Error(s) Free Programming

say noun('cow')->as_regex# (?^i:kine|cows|cow)

Page 36: Error(s) Free Programming

Does this help?

Page 37: Error(s) Free Programming

Not Really!

Page 38: Error(s) Free Programming

$word = noun('error');if ($count == 1) { say $word->singular;} else { say $word->plural;}

Page 39: Error(s) Free Programming

$word = noun('error');my $method = (count == 1) ? ‘singular’ : ‘plural’;

say $word->$method;

Page 40: Error(s) Free Programming

No Simpler

Page 41: Error(s) Free Programming
Page 42: Error(s) Free Programming

Easier interface

Page 43: Error(s) Free Programming

inflect()

Page 44: Error(s) Free Programming

inflect(“<#:$count> <N:error> <V:were> found”);

Page 45: Error(s) Free Programming

for (0 .. 5) { inflect(“<#:$_> <N:error> <V:were> found”);}

Page 46: Error(s) Free Programming

0 errors were found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 47: Error(s) Free Programming

0 errors were found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 48: Error(s) Free Programming

0 errors were found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 49: Error(s) Free Programming

inflect(“<#:$count> <N:error> <V:were> found”);

Page 50: Error(s) Free Programming

inflect(“<#:$count> <N:error> <V:were> found”);

Page 51: Error(s) Free Programming

<#:$count><N:error><V:were>

Page 52: Error(s) Free Programming

<#:$count><N:error><V:were>

Page 53: Error(s) Free Programming

<#:$count><N:error><V:were>

Page 54: Error(s) Free Programming

<#:$count><N:error><V:were>

Page 55: Error(s) Free Programming

<#:$count>

Page 56: Error(s) Free Programming

<N:error>

Page 57: Error(s) Free Programming

<V:were>

Page 58: Error(s) Free Programming

<A:our>

Page 59: Error(s) Free Programming

0 errors were found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 60: Error(s) Free Programming

Job Done!

Page 61: Error(s) Free Programming
Page 62: Error(s) Free Programming

But

Page 63: Error(s) Free Programming
Page 64: Error(s) Free Programming

0 errorsorno errors

Page 65: Error(s) Free Programming
Page 66: Error(s) Free Programming

<#:$count>

Page 67: Error(s) Free Programming

<#xx:$count>

Page 68: Error(s) Free Programming

<#xx:$count>

Page 69: Error(s) Free Programming

<#n:$count>

Page 70: Error(s) Free Programming

no errors were found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 71: Error(s) Free Programming

no errors were found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 72: Error(s) Free Programming
Page 73: Error(s) Free Programming

no errorsorno error

Page 74: Error(s) Free Programming

<#s:$count>

Page 75: Error(s) Free Programming

no error was found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 76: Error(s) Free Programming

no error was found1 error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 77: Error(s) Free Programming
Page 78: Error(s) Free Programming

1 errororan error

Page 79: Error(s) Free Programming

<#a:$count>

Page 80: Error(s) Free Programming

0 errors were foundan error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 81: Error(s) Free Programming

0 errors were foundan error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 82: Error(s) Free Programming
Page 83: Error(s) Free Programming

<#an:$count>

Page 84: Error(s) Free Programming

no errors were foundan error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 85: Error(s) Free Programming

no errors were foundan error was found2 errors were found3 errors were found4 errors were found5 errors were found

Page 86: Error(s) Free Programming
Page 87: Error(s) Free Programming

Words or Numbers?

Page 88: Error(s) Free Programming

<#w:$count>

Page 89: Error(s) Free Programming

zero errors were foundone error was foundtwo errors were foundthree errors were foundfour errors were foundfive errors were found

Page 90: Error(s) Free Programming

zero errors were foundone error was foundtwo errors were foundthree errors were foundfour errors were foundfive errors were found

Page 91: Error(s) Free Programming
Page 92: Error(s) Free Programming

Our users can’t count

Page 93: Error(s) Free Programming

WTF

Page 94: Error(s) Free Programming

“f*** the users”

Page 95: Error(s) Free Programming

<#f:$count>

Page 96: Error(s) Free Programming

no errors were foundone error was founda couple of errors were founda few errors were foundseveral errors were foundmany errors were found

Page 97: Error(s) Free Programming

no errors were foundone error was founda couple of errors were founda few errors were foundseveral errors were foundmany errors were found

Page 98: Error(s) Free Programming

for (0, 1, 2, 4, 7, 10) { …}

Page 99: Error(s) Free Programming
Page 100: Error(s) Free Programming

inflect()

Page 101: Error(s) Free Programming

Lazy

Page 102: Error(s) Free Programming

“Good enough” isn't

good enough

Page 103: Error(s) Free Programming
Page 104: Error(s) Free Programming
Page 105: Error(s) Free Programming
Page 106: Error(s) Free Programming

Damianware Merchandiseperlhacks.com/damian

All profits go to The Perl Foundation

Page 107: Error(s) Free Programming

Error(s) Free Programming

Dave Cross@davorg / @[email protected]

Page 108: Error(s) Free Programming