Upgrade to Pro — share decks privately, control downloads, hide ads and more …

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

hitode909
August 21, 2015

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

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

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

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

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

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

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

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

hitode909

August 21, 2015
Tweet

More Decks by hitode909

Other Decks in Technology

Transcript

  1. 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
  2. %#*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"; });
  3. %#*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"; });
  4. %#*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"; });
  5. 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
  6. EFMFUF@JG $list = List::Rubyish->new([1, 2, 3, 4]); $list->delete_if(sub { ($_

    % 2) == 0) }); $list->dump #=> [1, 3] IUUQTNFUBDQBOPSHQPE-JTU3VCZJTI
  7. 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; }
  8. 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; }
  9. $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'); }
  10. $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}); }
  11. ͦͷ࣮૷ 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; }
  12. อଘ ಺෦Ͱ͸*/4&35 sub register_new_blog { my ($class, $db, $values) =

    @_; ... my $blog = $db->execute( 'INSERT INTO blog ...
  13. هࣄ͸ෳࡶ 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 ...
  14. ‘;’ ߏจ໦ ‘print’ ‘ ‘ List ‘ ‘ ‘ ‘

    ‘1’ ‘ ‘ ‘*’ ‘ ‘ ‘2’ ‘+’ ‘3’ Statement Document print (1 * 2) + 3;
  15. ׬