Perlの上にも三年 〜 ずっとイケてるサービスを作り続ける技術 〜

Cc696ce673253d3bd21b3aa9e7927f39?s=47 hitode909
August 21, 2015

Perlの上にも三年 〜 ずっとイケてるサービスを作り続ける技術 〜

発表者は,この三年間はてなブログというイケてるPerlのサービスの開発に携ってきました…

Perlの最新を追い求め続けた三年間でした…

なにも分からず,SQLをコピペし続けた数ヶ月…

つらいことも,たのしいことも,みんな分かちあったコードベース…

救いを求め,藁にもすがる思いで,朝も夜も読み続けたオブジェクト指向入門……

偶然発見して,これだと思ったドメイン駆動設計……

苦しみの軌跡と,現在最高の設計を紹介します………!!!!!!!

Cc696ce673253d3bd21b3aa9e7927f39?s=128

hitode909

August 21, 2015
Tweet

Transcript

  1. 3.
  2. 5.
  3. 10.
  4. 11.
  5. 12.
  6. 13.
  7. 28.

    3JEHF package Bookmark::Engine::Index; use strict; use warnings; use Bookmark::Engine -Base;

    sub default : Public { my ($self, $r) = @_; $r->res->content_type('text/plain'); $r->res->content('Welcome to the Ridge world!'); } 1; IUUQTHJUIVCDPNIBUFOB)BUFOB5FYUCPPLCMPCNBTUFSNWDXFCBQQMJDBUJPONE
  8. 32.

    %#*Y.P$0 "DUJWF3FDPSE෩ͷ03. package Vocaloid::MoCo::Artist; use base 'DBIx::MoCo'; __PACKAGE__->table('artist'); my $artists

    = Vocaloid::MoCo::Artist->search( where => { name => { -like => 'ڸԻ%' }, }, order => 'id ASC', limit => 10, ); $artists->each(sub { print $_->name, "\n"; });
  9. 39.

    %#*Y.P$P-JTU 3VCZͷ"SSBZ෩ͷΠϯλʔϑΣΠε my $artists = Vocaloid::MoCo::Artist->search( where => { name

    => { -like => 'ڸԻ%' }, }, order => 'id ASC', limit => 10, ); $artists->each(sub { print $_->name, "\n"; });
  10. 40.

    %#*Y.P$P-JTU 3VCZͷ"SSBZ෩ͷΠϯλʔϑΣΠε ϦετΫϥε-JTU3VCZJTI my $artists = Vocaloid::MoCo::Artist->search( where => {

    name => { -like => 'ڸԻ%' }, }, order => 'id ASC', limit => 10, ); $artists->each(sub { print $_->name, "\n"; });
  11. 41.

    EFMFUF@JG $list = DBIx::MoCo::List->new([1, 2, 3, 4]); $list->delete_if(sub { ($_

    % 2) == 0) }); $list->dump #=> [2, 4] IUUQTNFUBDQBOPSHQPE%#*Y.P$P-JTU
  12. 42.

    EFMFUF@JG $list = List::Rubyish->new([1, 2, 3, 4]); $list->delete_if(sub { ($_

    % 2) == 0) }); $list->dump #=> [1, 3] IUUQTNFUBDQBOPSHQPE-JTU3VCZJTI
  13. 43.

    EFMFUF@JG # DBIx::MoCo#delete_if sub delete_if { my ($self, $code) =

    @_; croak "Argument must be a code" unless ref $code eq 'CODE'; my $last_index = $self->_last_index; for (0..$last_index) { my $item = $self->shift; local $_ = $item; $self->push($item) if $code->($_); } return $self; }
  14. 44.

    EFMFUF@JG # List::Rubyish sub delete_if { my ($self, $code) =

    @_; croak "Argument must be a code" unless ref $code eq 'CODE'; my $last_index = $self->_last_index; for (0..$last_index) { my $item = $self->shift; local $_ = $item; $self->push($item) unless $code->($_); } return $self; }
  15. 61.

    $POUSPMMFS ୯ͳΔΫϥεϝιου package Hatena::Epic::Admin::Index; use strict; use warnings; sub default

    { my ($class, $r) = @_; $r->res->content('Hello, World!'); $r->res->content_type('text/plain'); }
  16. 62.

    $POUSPMMFS 42-΋௚઀ൃߦ package Hatena::Epic::Admin::Index; use strict; use warnings; sub default

    { my ($class, $r) = @_; my $user = $r->db->single( 'SELECT * FROM user WHERE name=:name', bind => { name => 'sampleuser', }, class => 'Model::User', ); $r->render('index.html', {user => $user}); }
  17. 66.
  18. 77.
  19. 80.
  20. 89.

    ͦͷ࣮૷ 42-खॻ͖ sub find_user_by_name { my ($class, $db, $name) =

    @_; my $user = $db->single( 'SELECT * FROM user WHERE name=:name', bind => { name => $name, }, class => 'Model::User', ); return $user; }
  21. 91.

    อଘ ಺෦Ͱ͸*/4&35 sub register_new_blog { my ($class, $db, $values) =

    @_; ... my $blog = $db->execute( 'INSERT INTO blog ...
  22. 106.
  23. 111.
  24. 112.
  25. 116.
  26. 132.
  27. 149.

    هࣄ͸ෳࡶ WBMVFTͷLFZ͕ݸʙ Service::PostEntry->post($db, %values); title body date url categories user_id

    blog_id comment_count og_image og_description permission is_scheduled ...
  28. 158.
  29. 166.

    ‘;’ ߏจ໦ ‘print’ ‘ ‘ List ‘ ‘ ‘ ‘

    ‘1’ ‘ ‘ ‘*’ ‘ ‘ ‘2’ ‘+’ ‘3’ Statement Document print (1 * 2) + 3;
  30. 177.
  31. 178.
  32. 199.
  33. 203.
  34. 205.
  35. 206.
  36. 209.
  37. 210.
  38. 221.
  39. 244.
  40. 246.
  41. 247.
  42. 248.
  43. 249.
  44. 250.
  45. 251.
  46. 258.
  47. 262.

    ׬