when your code is nearly old enough to vote

40
When Your Codebase Is Nearly Old Enough To Vote Denise Paolucci Dreamwidth Studios - www.dreamwidth.org Slides: www.slideshare.net/dreamwidth Friday, January 16, 15

Upload: dreamwidth

Post on 14-Jul-2015

499 views

Category:

Technology


4 download

TRANSCRIPT

Page 1: When your code is nearly old enough to vote

When Your Codebase Is Nearly Old Enough

To Vote

Denise PaolucciDreamwidth Studios - www.dreamwidth.org

Slides: www.slideshare.net/dreamwidth

Friday, January 16, 15

Page 2: When your code is nearly old enough to vote

At time of fork:

• Perl 5.6

• Apache 1.3 (yes, in 2008!)

• BML (custom template language from 1996)

• Various Perl modules (usually outdated)

Friday, January 16, 15

Page 3: When your code is nearly old enough to vote

hic sunt dracones

Friday, January 16, 15

Page 4: When your code is nearly old enough to vote

Comments that don’t help my $out_straight = sub {

# Hacky: forces text flush. see:

# http://zilla.livejournal.org/906

if ($need_flush) {

$cleaner->parse("<!-- -->");

$need_flush = 0;

}

Friday, January 16, 15

Page 5: When your code is nearly old enough to vote

Comments that don’t help my $out_straight = sub {

# Hacky: forces text flush. see:

# http://zilla.livejournal.org/906

if ($need_flush) {

$cleaner->parse("<!-- -->");

$need_flush = 0;

}

(Six bug trackers and four owners ago.)

Friday, January 16, 15

Page 6: When your code is nearly old enough to vote

Workarounds for outdated browsers

// let me explain this. Opera 8 does XMLHttpRequest, but not setRequestHeader.

// no problem, we thought: we'll test for setRequestHeader and if it's not present

// then fall back to the old behavior (treat it as not working). BUT --- IE6 won't

// let you even test for setRequestHeader without throwing an exception (you need

// to call .open on the .xtr first or something)

Friday, January 16, 15

Page 7: When your code is nearly old enough to vote

Workarounds for outdated browsers

// let me explain this. Opera 8 does XMLHttpRequest, but not setRequestHeader.

// no problem, we thought: we'll test for setRequestHeader and if it's not present

// then fall back to the old behavior (treat it as not working). BUT --- IE6 won't

// let you even test for setRequestHeader without throwing an exception (you need

// to call .open on the .xtr first or something)

Current Opera: 26.0.1656.60 (Opera 8 released 2005)Current IE: 11.0.12 (IE 6 released 2001)

Friday, January 16, 15

Page 8: When your code is nearly old enough to vote

Really old HTML $ret .= "<FORM METHOD=POST>"; $ret .= LJ::form_auth(); $ret .= "<TABLE WIDTH=400><TR VALIGN=BOTTOM>"; $ret .= "<TD><IMG SRC=\"$LJ::IMGPREFIX/nerd_small.jpg\" WIDTH=167 HEIGHT=169 HSPACE=2 VSPACE=2></TD>"; $ret .= "<TD><B><TT>command console.</TT></B>"; $ret .= "<P>welcome to the livejournal console. from here administrators can do administrative type things. you will forget the commands, so there is a <A HREF=\"reference.bml\">reference</A>.</TD>"; $ret .= "</TR>"; $ret .= "<TR><TD COLSPAN=2>"; $ret .= "<P><tt>enter commands:</tt><BR>"; $ret .= "<TEXTAREA NAME=commands ROWS=10 COLS=60 WRAP=OFF></TEXTAREA></TD></TR>\n"; $ret .= "<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=SUBMIT VALUE=\"execute\"></P></TD></TR></TABLE></FORM>\n"; return $ret;

Friday, January 16, 15

Page 9: When your code is nearly old enough to vote

Really old HTML $ret .= "<FORM METHOD=POST>"; $ret .= LJ::form_auth(); $ret .= "<TABLE WIDTH=400><TR VALIGN=BOTTOM>"; $ret .= "<TD><IMG SRC=\"$LJ::IMGPREFIX/nerd_small.jpg\" WIDTH=167 HEIGHT=169 HSPACE=2 VSPACE=2></TD>"; $ret .= "<TD><B><TT>command console.</TT></B>"; $ret .= "<P>welcome to the livejournal console. from here administrators can do administrative type things. you will forget the commands, so there is a <A HREF=\"reference.bml\">reference</A>.</TD>"; $ret .= "</TR>"; $ret .= "<TR><TD COLSPAN=2>"; $ret .= "<P><tt>enter commands:</tt><BR>"; $ret .= "<TEXTAREA NAME=commands ROWS=10 COLS=60 WRAP=OFF></TEXTAREA></TD></TR>\n"; $ret .= "<TR><TD COLSPAN=2 ALIGN=RIGHT><INPUT TYPE=SUBMIT VALUE=\"execute\"></P></TD></TR></TABLE></FORM>\n"; return $ret;

(1999 called; they want their tables back)

Friday, January 16, 15

Page 10: When your code is nearly old enough to vote

Out of date special-casing

# Catch misspellings of hotmail.com if ($domain =~ /^(otmail|hotmial|hotmil|hotamail|hotmaul|hoatmail|hatmail|htomail)\.(cm|co|com|cmo|om)$/ or $domain =~ /^hotmail\.(cm|co|om|cmo)$/) { return $reject->("bad_hotmail_spelling", "You gave $email as your email address. Are you sure you didn't mean hotmail.com?"); }

# Catch misspellings of aol.com elsif ($domain =~ /^(ol|aoll)\.(cm|co|com|cmo|om)$/ or $domain =~ /^aol\.(cm|co|om|cmo)$/) { return $reject->("bad_aol_spelling", "You gave $email as your email address. Are you sure you didn't mean aol.com?"); }

Friday, January 16, 15

Page 11: When your code is nearly old enough to vote

Out of date special-casing

# Catch misspellings of hotmail.com if ($domain =~ /^(otmail|hotmial|hotmil|hotamail|hotmaul|hoatmail|hatmail|htomail)\.(cm|co|com|cmo|om)$/ or $domain =~ /^hotmail\.(cm|co|om|cmo)$/) { return $reject->("bad_hotmail_spelling", "You gave $email as your email address. Are you sure you didn't mean hotmail.com?"); }

# Catch misspellings of aol.com elsif ($domain =~ /^(ol|aoll)\.(cm|co|com|cmo|om)$/ or $domain =~ /^aol\.(cm|co|om|cmo)$/) { return $reject->("bad_aol_spelling", "You gave $email as your email address. Are you sure you didn't mean aol.com?"); }

80-90% of our new signups are from @gmail.com

Friday, January 16, 15

Page 12: When your code is nearly old enough to vote

Old bad decisions (that were right at the time)

# remove the SvUTF8 flag. it's still UTF-8, but

# we don't want perl knowing that and messing stuff up

# for us behind our back in random places all over

# http://zilla.livejournal.org/show_bug.cgi?id=1037

foreach my $attr (qw(id subject text link author)) {

next unless exists $it->{$attr} && defined $it->{$attr};

$it->{$attr} = LJ::no_utf8_flag ( $it->{$attr} );

}

Friday, January 16, 15

Page 13: When your code is nearly old enough to vote

And more...

Friday, January 16, 15

Page 14: When your code is nearly old enough to vote

And more...

• Outdated modules

Friday, January 16, 15

Page 15: When your code is nearly old enough to vote

And more...

• Outdated modules

• Ancient JavaScript

Friday, January 16, 15

Page 16: When your code is nearly old enough to vote

And more...

• Outdated modules

• Ancient JavaScript

• Massive duplication

Friday, January 16, 15

Page 17: When your code is nearly old enough to vote

And more...

• Outdated modules

• Ancient JavaScript

• Massive duplication

• Bugs that had turned into features

Friday, January 16, 15

Page 18: When your code is nearly old enough to vote

Should you rewrite?

Friday, January 16, 15

Page 19: When your code is nearly old enough to vote

Upgrading Apache

BENEFIT COST

• Moving away from software at EOL

• So much time. (circa 6 months to working

prototype)

• Security fixes • New and exciting bugs

• Not having to downgrade new installs

• But really, a no-brainer

• Easier to explain

• No longer horribly ashamed of ourselves

Friday, January 16, 15

Page 20: When your code is nearly old enough to vote

Switch to Foundation

BENEFIT COST

• Modern framework • So many pages

• Responsive design (better mobile)

• Changes to look/feel (our users are picky)

• Better cross-browser • New and exciting bugs

• Easier to make accessible

• Less individual

• Well documented • No, seriously, SO MUCH WORK

• Kill lurking old HTML • We’re still not doneFriday, January 16, 15

Page 21: When your code is nearly old enough to vote

The pros: will you...

Friday, January 16, 15

Page 22: When your code is nearly old enough to vote

The pros: will you...

• become more compatible with standards/best practices?

Friday, January 16, 15

Page 23: When your code is nearly old enough to vote

The pros: will you...

• become more compatible with standards/best practices?

• make your code easier to install?

Friday, January 16, 15

Page 24: When your code is nearly old enough to vote

The pros: will you...

• become more compatible with standards/best practices?

• make your code easier to install?

• eliminate project-specific systems?

Friday, January 16, 15

Page 25: When your code is nearly old enough to vote

The pros: will you...

• become more compatible with standards/best practices?

• make your code easier to install?

• eliminate project-specific systems?

• reduce reliance on institutional memory?

Friday, January 16, 15

Page 26: When your code is nearly old enough to vote

The pros: will you...

• become more compatible with standards/best practices?

• make your code easier to install?

• eliminate project-specific systems?

• reduce reliance on institutional memory?

• benefit your users or your team?

Friday, January 16, 15

Page 27: When your code is nearly old enough to vote

The cons: will you...

Friday, January 16, 15

Page 28: When your code is nearly old enough to vote

The cons: will you...

• lose a history of bugfixes or security fixes?

Friday, January 16, 15

Page 29: When your code is nearly old enough to vote

The cons: will you...

• lose a history of bugfixes or security fixes?

• tie up too many of your people, or involve too much retraining?

Friday, January 16, 15

Page 30: When your code is nearly old enough to vote

The cons: will you...

• lose a history of bugfixes or security fixes?

• tie up too many of your people, or involve too much retraining?

• be tied to something that might not last?

Friday, January 16, 15

Page 31: When your code is nearly old enough to vote

The cons: will you...

• lose a history of bugfixes or security fixes?

• tie up too many of your people, or involve too much retraining?

• be tied to something that might not last?

• need to fork/adapt a standard/module?

Friday, January 16, 15

Page 32: When your code is nearly old enough to vote

The cons: will you...

• lose a history of bugfixes or security fixes?

• tie up too many of your people, or involve too much retraining?

• be tied to something that might not last?

• need to fork/adapt a standard/module?

• not benefit your users or your team?

Friday, January 16, 15

Page 33: When your code is nearly old enough to vote

The number one question:

Friday, January 16, 15

Page 34: When your code is nearly old enough to vote

Will you finish it?

Friday, January 16, 15

Page 35: When your code is nearly old enough to vote

Future-proofing

Friday, January 16, 15

Page 36: When your code is nearly old enough to vote

Future-proofing

• Comment everything, in the code itself

Friday, January 16, 15

Page 37: When your code is nearly old enough to vote

Future-proofing

• Comment everything, in the code itself

• Be grep friendly

Friday, January 16, 15

Page 38: When your code is nearly old enough to vote

Future-proofing

• Comment everything, in the code itself

• Be grep friendly

• Write task lists for your future self

Friday, January 16, 15

Page 39: When your code is nearly old enough to vote

Future-proofing

• Comment everything, in the code itself

• Be grep friendly

• Write task lists for your future self

• Regularly install/compile from scratch

Friday, January 16, 15

Page 40: When your code is nearly old enough to vote

Thank you!Denise Paolucci

Dreamwidth Studios - www.dreamwidth.orgSlides: www.slideshare.net/dreamwidth

Friday, January 16, 15