SlideShare ist ein Scribd-Unternehmen logo
1 von 24
Downloaden Sie, um offline zu lesen
(    )         ;'.
    Strategy

               @daisuke_m
         2011/04/25
• @daisuke_m
• @j5ik2o
•
• Java
• Jiemamy
• Apache Mahout
Strategy
•
•
•
•    (   )
             →
•   …
http://ja.wikipedia.org/
wiki/Strategy_
"   "
• java.io.File
"   "
• java.io.File
"   "
• java.io.File
"   "
• java.io.File
"   "
• java.io.File
File
•…
 •                     …

 •
 •                         …

•   file1, file2, file10   …
Strategy
• case1 :
 •
• case2 : if   elseif   elseif…

 •
/* case1 */
void sort(List<File> target) {
  // sort by name
}

/* case2 */
void sort(List<File> target, String type) {
  if ("name".equasls(type)) {
    // sort by name
  } else if ("size".equals(type)) {
    // sort by size
  } else {
    // default ...
  }
}
Strategy

• case 3 :       (   )

 •
• case 4 :
 •
•"   "
Strategy
•
    •
•
    •
    •        →
    • SQL   → RDBMS
•
public interface Strategy {
  String process(int i);
}


public class Client {

    Strategy strategy;

    public Client(Strategy strategy) {
      this.strategy = strategy;
    }

    public void run() {
      for (int i = 1; i <= 100; i++) {
        System.out.println(strategy.process(i);
      }
    }
}
/*          FizzBuzz */
public class FizzBuzzStrategy implements Strategy {
  public String process(int i) {
    if (i % 3 == 0 && i % 5 == 0) return "FizzBuzz";
    if (i % 3 == 0) return "Fizz";
    if (i % 5 == 0) return "Buzz";
    return String.valueOf(i);
  }
}


/*          Nabeatsu */
public class NabeatsuStrategy implements Strategy {
  public String process(int i) {
    if (i % 3 == 0 || String.valueOf(i).contains("3")) {
      return i + "   ( ´Д` ) ";;
         }
         return String.valueOf(i);
     }
}
Client c = new Client(   );
          c.run();

new FizzBuzzStrategy()      new NabeatsuStrategy()
          FizzBuzz                      Nabeatsu
  1                           1
  2                           2
  Fizz                        3 ( ´Д` )
  4                           4
  Buzz                        5
  Fizz                        6 ( ´Д` )
  7                           7
  8                           8
                              9  ( ´Д` )
  Fizz
  Buzz                        10
  11                          11
                              12  ( ´Д` )
  Fizz
  13                          13  ( ´Д` )

Weitere ähnliche Inhalte

Mehr von 都元ダイスケ Miyamoto

アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019
アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019
アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019都元ダイスケ Miyamoto
 
マイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDay
マイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDayマイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDay
マイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDay都元ダイスケ Miyamoto
 
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)都元ダイスケ Miyamoto
 
20170312 F.K様向け ライフパートナーM.M様のご提案
20170312 F.K様向け ライフパートナーM.M様のご提案20170312 F.K様向け ライフパートナーM.M様のご提案
20170312 F.K様向け ライフパートナーM.M様のご提案都元ダイスケ Miyamoto
 
20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編
20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編
20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編都元ダイスケ Miyamoto
 
20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...
20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...
20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...都元ダイスケ Miyamoto
 
20121206 VOYAGE LT - 名前重要って言うけどさ
20121206 VOYAGE LT - 名前重要って言うけどさ20121206 VOYAGE LT - 名前重要って言うけどさ
20121206 VOYAGE LT - 名前重要って言うけどさ都元ダイスケ Miyamoto
 
20120830 DBリファクタリング読書会第三回
20120830 DBリファクタリング読書会第三回20120830 DBリファクタリング読書会第三回
20120830 DBリファクタリング読書会第三回都元ダイスケ Miyamoto
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻都元ダイスケ Miyamoto
 
DevelopersSummit2011 【17-E-1】 DBも変化せよ - Jiemamy
DevelopersSummit2011 【17-E-1】 DBも変化せよ - JiemamyDevelopersSummit2011 【17-E-1】 DBも変化せよ - Jiemamy
DevelopersSummit2011 【17-E-1】 DBも変化せよ - Jiemamy都元ダイスケ Miyamoto
 
とべとべ電設部勉強会20100717 DB meets Jiemamy
とべとべ電設部勉強会20100717  DB meets Jiemamyとべとべ電設部勉強会20100717  DB meets Jiemamy
とべとべ電設部勉強会20100717 DB meets Jiemamy都元ダイスケ Miyamoto
 

Mehr von 都元ダイスケ Miyamoto (20)

アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019
アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019
アプリケーション動作ログ、
ERRORで出すか? WARNで出すか? #cmdevio2019
 
マイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDay
マイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDayマイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDay
マイクロサービス時代の認証と認可 - AWS Dev Day Tokyo 2018 #AWSDevDay
 
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
クラスメソッドにおける Web API エンジニアリングの基本的な考え方と標準定義 - Developers.IO 2018 (2018-10-05)
 
AWSクラウドデータストレージ総論
AWSクラウドデータストレージ総論AWSクラウドデータストレージ総論
AWSクラウドデータストレージ総論
 
20170312 F.K様向け ライフパートナーM.M様のご提案
20170312 F.K様向け ライフパートナーM.M様のご提案20170312 F.K様向け ライフパートナーM.M様のご提案
20170312 F.K様向け ライフパートナーM.M様のご提案
 
体で覚えるSQS! DEVIO-MTUP11-TOKYO-007
体で覚えるSQS! DEVIO-MTUP11-TOKYO-007体で覚えるSQS! DEVIO-MTUP11-TOKYO-007
体で覚えるSQS! DEVIO-MTUP11-TOKYO-007
 
20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編
20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編
20140315 JAWS DAYS 2014 ACEに聞け! CloudFormation編
 
20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...
20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...
20131210 CM re:Growth - Infrastructure as Code から Full Reproducible Infrastru...
 
20130516 cm課外授業8-aws
20130516 cm課外授業8-aws20130516 cm課外授業8-aws
20130516 cm課外授業8-aws
 
20121215 DevLOVE2012 Mahout on AWS
20121215 DevLOVE2012 Mahout on AWS20121215 DevLOVE2012 Mahout on AWS
20121215 DevLOVE2012 Mahout on AWS
 
20121206 VOYAGE LT - 名前重要って言うけどさ
20121206 VOYAGE LT - 名前重要って言うけどさ20121206 VOYAGE LT - 名前重要って言うけどさ
20121206 VOYAGE LT - 名前重要って言うけどさ
 
20120830 DBリファクタリング読書会第三回
20120830 DBリファクタリング読書会第三回20120830 DBリファクタリング読書会第三回
20120830 DBリファクタリング読書会第三回
 
DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻DevLOVE Beautiful Development - 第一幕 陽の巻
DevLOVE Beautiful Development - 第一幕 陽の巻
 
DevelopersSummit2011 【17-E-1】 DBも変化せよ - Jiemamy
DevelopersSummit2011 【17-E-1】 DBも変化せよ - JiemamyDevelopersSummit2011 【17-E-1】 DBも変化せよ - Jiemamy
DevelopersSummit2011 【17-E-1】 DBも変化せよ - Jiemamy
 
とべとべ電設部勉強会20100717 DB meets Jiemamy
とべとべ電設部勉強会20100717  DB meets Jiemamyとべとべ電設部勉強会20100717  DB meets Jiemamy
とべとべ電設部勉強会20100717 DB meets Jiemamy
 
2009-11-20 DevLOVE 2009 DB勉強会
2009-11-20 DevLOVE 2009 DB勉強会2009-11-20 DevLOVE 2009 DB勉強会
2009-11-20 DevLOVE 2009 DB勉強会
 
Seasar Conference 2009 Spring - Jiemamy
Seasar Conference 2009 Spring - JiemamySeasar Conference 2009 Spring - Jiemamy
Seasar Conference 2009 Spring - Jiemamy
 
Seasar Conference 2009 White - DI
Seasar Conference 2009 White - DISeasar Conference 2009 White - DI
Seasar Conference 2009 White - DI
 
Jiemamy inside 2
Jiemamy inside 2Jiemamy inside 2
Jiemamy inside 2
 
Jiemamy inside 1
Jiemamy inside 1Jiemamy inside 1
Jiemamy inside 1
 

Kürzlich hochgeladen

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 

Kürzlich hochgeladen (20)

Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 

java-ja 第1回 チキチキ『( ゜ェ゜)・;'.、ゴフッ』 - Strategy

  • 1. ( ) ;'. Strategy @daisuke_m 2011/04/25
  • 2. • @daisuke_m • @j5ik2o • • Java • Jiemamy • Apache Mahout
  • 4.
  • 6. " " • java.io.File
  • 7. " " • java.io.File
  • 8. " " • java.io.File
  • 9. " " • java.io.File
  • 10. " " • java.io.File
  • 11. File •… • … • • … • file1, file2, file10 …
  • 12. Strategy • case1 : • • case2 : if elseif elseif… •
  • 13. /* case1 */ void sort(List<File> target) { // sort by name } /* case2 */ void sort(List<File> target, String type) { if ("name".equasls(type)) { // sort by name } else if ("size".equals(type)) { // sort by size } else { // default ... } }
  • 14. Strategy • case 3 : ( ) • • case 4 : •
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20. •" "
  • 21. Strategy • • • • • → • SQL → RDBMS •
  • 22. public interface Strategy { String process(int i); } public class Client { Strategy strategy; public Client(Strategy strategy) { this.strategy = strategy; } public void run() { for (int i = 1; i <= 100; i++) { System.out.println(strategy.process(i); } } }
  • 23. /* FizzBuzz */ public class FizzBuzzStrategy implements Strategy { public String process(int i) { if (i % 3 == 0 && i % 5 == 0) return "FizzBuzz"; if (i % 3 == 0) return "Fizz"; if (i % 5 == 0) return "Buzz"; return String.valueOf(i); } } /* Nabeatsu */ public class NabeatsuStrategy implements Strategy { public String process(int i) { if (i % 3 == 0 || String.valueOf(i).contains("3")) { return i + " ( ´Д` ) ";; } return String.valueOf(i); } }
  • 24. Client c = new Client( ); c.run(); new FizzBuzzStrategy() new NabeatsuStrategy() FizzBuzz Nabeatsu 1 1 2 2 Fizz 3 ( ´Д` ) 4 4 Buzz 5 Fizz 6 ( ´Д` ) 7 7 8 8 9 ( ´Д` ) Fizz Buzz 10 11 11 12 ( ´Д` ) Fizz 13 13 ( ´Д` )