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

ORM使いたい、あと伝えたいこと

 ORM使いたい、あと伝えたいこと

社内向け説明資料

threetreeslight

October 03, 2013
Tweet

More Decks by threetreeslight

Other Decks in Technology

Transcript

  1. „ƒç~¡ÙåqÙÍ   „ƒ       ORMāÍàÍ     Þëàõêö~¡ÙåòÙÍ

          WebăĨijďĹēıĸëĕďĹIJĥijĜĄāäàõêìRESTfullçÍΓ Ï`Ò9     RESTfullé“Ï`ìĉħĔćčĞZ.ëMVCĦĵĹĬķĹčç…NÒ˜Í     MVCĦĵĹĬķĹč췂&|Ò˜Í     ĉħĔćčĞZ.MVCëModel³ ìÇORMāÎ緂Òn   Ļű!æéÍçÖÿø¸°ãåÍýçÖÿöhüóÛÒǞ®ÙåØÍļ  
  2. Web  Applica�onæ9 éÖç     ĕďĹIJĥijĜĄ:     – ÍãîÍăčĖĕÙåÓåö9:ĺ  

    ĻÛ×ÍđĹģĹāÎ`uāºÔļ     &|:   – ·‚ÒbÍĺĭĸĜĠĸĕÒnĺ   Ļ ]ā4øÛçÍÎ`uāºÔļ  
  3. Ques�on:  èÎøãåÊÍãîÍăčĖĕÙåÓåö9:Ëêł   Answer:  đĹģĹæëmāwûÞÎĺ     đĹģĹæëmë#wìÇREST(Representa�onal  State  Transfer)

     é“Ï` ĻRESTfullļā±€Ûþí>}æÓóÛÈ   1.  ĕĜĹĞĵĕ(State  less)éčIJąăĸĞ/đĹģĨĶĞĐĴ   2.  ÛñåëQ3Â(ijėĹĕ)  ê±€æÓýÊúÔ=‘Øþà\ËëĖĚĞ   3.  ijėĹĕāRê¨"ÛýÊr€ƒéo^Ë   4.  ăĨijďĹēıĸëQ3ç{S²‰ë`āWÎÖçÒæÓýÊĢąĤĹĭ ĝĄăë€Ë  
  4. ŀÆĕĜĹĞÊĦĴËéĢĸģĹċĹēıĚĨ ĕĘĚĦ   ?A   v^èÎéØÍóÛÑł   ?AæÛÈĢĸģĹċĹØÍ   ĩĜĞìèÎéØÍóÛÑł

      ÀôzìèÎéØþóÛÑł   ĩĜĞöØÍÈ   ĐĹIJÔáØÍÈ   ³æľĿĽêéüóÛÈ  
  5.   ĕĘĚĦĻđĹģĹļÒ   ?ĻčIJąăĸĞļë{Sā   ¢TÛýLÒÌý     äóüÇÍãîÍ?Òjýç0 ¢TÛýLÒÌýëæÇĕďĹĴÒ1

    ½ÈĻŁPÙÍÑéÇ}™ëăĨijďĹēıĸë{tļ   ĕĜĹĞÊĦĴËéĢĸģĹċĹēıĚĨìÇ  
  6. ŀÆĕĜĹĞÊĵĕËéĢĸģĹċĹēıĚĨ   ĕĘĚĦ   ?   v^èÎéØÍóÛÑł   ?AæÛÈĢĸģĹċĹØÍ  

    ĩĜĞìèÎéØÍóÛÑł   ÀôzìèÎéØþóÛÑł   ?AæÛÈĢĸģĹċĹçĩĜĞØÍ   ?AæÛÈĢĸģĹċĹçĩĜĞçĐĹIJÔáØÍÈ   ³æľĿĽêéüóÛÈ  
  7. Ques�on:ÆèÎøãåĕĜĹĞĵĕā>}ÛýëÑł   Answer:  ÆURI  (  URL  )āÏíjóÛÈ      

    ôĂéúԞýĐąěæÛÈ h�p://weather.yahoo.co.jp/weather/jp/13/4410.html       RESTëÊijėĹĕāRê¨"Ûýr€ƒéo^Ëê…FÙóÛÈ    
  8. ŀÆĢĸģĹċĹēıĚĨëURI     ĕĘĚĦĻđĹģĹļðëv^   –  ?ŀÆ?A   –  ĭąĸĭġįĹŀÆĢĸģĹċĹ

      –  đħĭġįĹŀÆĩĜĞ   –  ğijĸčŀÆĐĹIJ     h�p://macdnald.com/client/a/orders/new/main/burger/sub/potato/drink/coke   ÐD   ?A   ĢĸģĹċĹ   ĩĜĞ   ĐĹIJ   ăčēıĸ  
  9. ŀÆĢĸģĹċĹēıĚĨëURI   ?ë™'ÛñåāURIæšÛçÏíÇÇÇ     v^   h�p://macdnald.com/client/a/orders/new/main/burger/sub/potato/drink/coke    

    v^@ë­%   h�p://macdnald.com/client/a/add_order/1/sub/cheese     v^ëČĮĸĖĴ   h�p://macdnald.com/client/a/delete_order/1     v^ë   h�p://macdnald.com/client/a/orders     v^륏   h�p://macdnald.com/client/a/orders/1  
  10. ÖþæĕĜĹĞĵĕÒ>}æÓýÒÇÇÇ   1.  v^øv^@ā­%ÛýURIÒy¹ê¶ÔéýëÒ«Í   h�p://macdnald.com/client/a/orders/new/main/burger/sub/potato/drink/coke   2.  ĕĘĚĦÒ¸°Ïåv^­%Ùâ÷ãàüÇaêČĮĸĖĴÙàv^āE ČĮĸĖĴÙúÎçÙå¬ĀéÍÑł

      Ļ,ÚURIêăčĖĕÙåÇâ÷Ăç,Ú{SÒXĻ‹NļØþýëÑļ   h�p://macdnald.com/client/a/delete_order/1         éèÇ?ĻđĹĥĕļöĕĘĚĦĻđĹģĹļöK´ Ò8ÍÈ     ĐĐ   ĐĐ  
  11. ŀÆøüàÍ çHTTPĭėĚğëĪĚĨ HTTPĭ ĭė ėĚ Ěğ ğ   ? ?ë

    ë' '    DBë ë\ \  (CRUD)   , ,Ú Ú{ {S Së ë   X X Ļ Ļ ‹ ‹N Nļ ļ   POST   v^ë­%   CREATE   yÙ   GET   v^@ë)J   v^ ë)J   READ   hü   PUT/PATCH   v^@ëf_   UPDATE   ³Çhü   Ļf_A© 7êG ¾āÏéÍàõļ   DELETE   v^ëČĮĸĖĴ   DELETE   hü  
  12. ŀÆ>»ëURL     ĉĹęĹë   h�p://macdnald.com/client/a/orders       ĉĹęĹë­%

      h�p://macdnald.com/client/a/orders/new       ĉĹęĹ륏   h�p://macdnald.com/client/a/orders/4123       ĉĹęĹë6f   h�p://macdnald.com/client/a/orders/4123       ĉĹęĹëČĮĸĖĴ   h�p://macdnald.com/client/a/orders/4123     POST   GET   DELETE   GET   PUT   HTTP  method   URL  
  13. ĕďĹIJĥijĜĄëóçõ     ĕďĹIJĥijĜĄā>}ÛýàõêìRESTfullêÙú Îĺ     RESTfullì ë@ā±!ê>›ÙúÎĺ  

    –  ĕĜĹĞĵĕêÛýÈ   –  ĕĜĹĞĵĕêÛýêìÇURIê{SāYàÝúÎÈ   –  URIā<êWÎêìÇøüàÍ ç +ãàHTTPĭėĚğ āÐÎ  
  14. &|ë˜Íweb  applica�on·‚   1.  G¾Œ2Ò ÑüøÛÍ   –  ĨĶĎIJĬ,5ҁ+(  loose

     coupling)æÌýÈ     MVC  framework  !!!   1.  §ÒžåöáÍàÍêÒhýëÑÒ~¡æÓýÈ   –  ĨĶĎIJĬëH$ĻDBçëøüçüÇHTMLëUļÒc†ê Ñþå ÍýÈ   MVC  framework  !!!    
  15. MVCăĨijďĹēıĸë   čIJąăĸĞ   1.  HTTPijčĈĕĞ     (URI,  HTTPĭėĚğ)

      Rou�ng  /     Dispatcher   Controller   DB   Model   2.  URIçĭėĚğë¡k   View   3.  ăčēıĸĻ~ļëZ=   5.  DBðë~   ĻCRUDļ   8.  İĹĒŚ‡HTMLāU   4   6   7   9   10.HTTPĵĕĩĸĕ   Applica�on  
  16. >}êÐÍå½ÙÍĩąĸĞ   DB   Model   5.  DBðë~   ĻCRUDļ

        RDBçĻObjectZ.ëļMVCìÇʅNÒOÍËÈ           liƒé“Ï`Ò°ÎàõǂÙåÍýÈ   –  RDBìÇÃàáëĻĕĊIJĹļÄ   –  ObjectìÇÃ[ý—ÍĻĭėĚğļçCNĻĭĸģļÄ  
  17. ÞÖæORM    (Object-­‐rela�onal  mapping)     *ÉëĜĹħĴāÞþßþClassçÙåWÎÈ     ĜĹħĴëĊIJĬìǤFÛýčIJĕëCNĻĭĸģļçÙåWÎÈ

        ĜĹħĴðë\ìUserModelÑû™ÎÈ   Class  User  extends  Model  {   }     User  Table   =   Class  User  extends  Model  {    protected  name   }   User  Table   -­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐-­‐   Name  |  varchar(256)   =   $user  =  User::find_by_id(3000);   $user.name  //=  akira   SELECT  *  FROM  user     WHERE  id  =  3000;     //  id                |  name   //  -­‐-­‐-­‐-­‐          |-­‐-­‐-­‐-­‐-­‐   //    3000  |  akira   =  
  18. gIêÇĨĶĎIJīĸĎāÛýàõëKoÏ   ĻçÍÎ-ëпÍļ     CoC:  conven�on  over  configura�on  

    –  Ÿì·‚”ës=ÛñÓÖçĻ£=ļāwBØÝÇ(ŽêÛý     DRY:  Don’t  Repeat  Yourself   –  Q3뵜ì6fë1½Øā49Ù¯cNāwBØÝÇ–āÚý   ĻvRŀ  No  Once  and  Only  One(  OAOO  )  ļ     KISS:  Keep  it  Simple,  Stupid   –  ėĦĞĆćăҜ¼êéýêäþåÇÍ`ā’JÛýe¸Ò4ÏàüÇ\êV¸ )ãàüÇèþÒµép•éëÑ ÑûéÔéýÈ     YAGNI:  You  ain’t  gonna  need  it   –  p•ì>»êLçéýóæì­%ÙéÍëÒúÍÈÌçæÎáÿÎçëxëê ãàöëìÇ>»êì10%ŠEÙÑĀþéÍÈÙàÒãåÞþêªøÙàe¸ë 90%ìyÁêéýÈ