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

はじめてのIT勉強会.pdf

unisuke
September 23, 2020
110

 はじめてのIT勉強会.pdf

unisuke

September 23, 2020
Tweet

Transcript

  1. class : class StatsKeeper { public: //doubleを記録するクラス void Add(double d);

    //とすばやくとうけいを出すメ ソッド private int count; /*それまでの 個数*/ public: double Average(); private: double minimum; list<double> part_items ; double maximam; }; //doubleを記録するクラス //とすばやく統計を出すメソッド class StatsKeeper { public: void Add(double d); double Average(); private: list<double> part_items; int count; //それまでの個数 double minimum; double maximam; };
  2. public class PerformanceTester{ publicstaticfinalTcpConnectionSimulatorwifi= newTcpConnectionSimulator( 500, /* Kbps*/ 80,/* millisecslatency

    */ 200,/* jitter*/ 1/* packet loss %*/); public static final TcpConnectionSimulatort3_fiber = newTcpConnectionSimulator( 45000, /* Kbps*/ 10, /* millisecslatency */ 0,/* jitter*/ 0/* packet loss %*/); public static final TcpConnectionSimulatorcell= newTcpConnectionSimulator( 100,/* Kbps*/ 400,/* millisecslatency */ 250,/* jitter*/ 5/* packet loss %*/); }
  3. public class PerformanceTester{ publicstaticfinalTcpConnectionSimulatorwifi= newTcpConnectionSimulator( 500, /* Kbps*/ 80,/* millisecslatency

    */ 200,/* jitter*/ 1/* packet loss %*/); public static final TcpConnectionSimulatort3_fiber = newTcpConnectionSimulator( 45000, /* Kbps*/ 10, /* millisecslatency */ 0,/* jitter*/ 0/* packet loss %*/); public static final TcpConnectionSimulatorcell= newTcpConnectionSimulator( 100,/* Kbps*/ 400,/* millisecslatency */ 250,/* jitter*/ 5/* packet loss %*/); } シルエットが変なので自然と 目が行ってしまう 3つのインスタンス、で似て いるものなのに似ているよう に見えない
  4. public class PerformanceTester{ public static final TcpConnectionSimulatorwifi= newTcpConnectionSimulator( 500, /*

    Kbps*/ 80, /* millisecslatency*/ 200, /* jitter */ 1 /* packet loss % */); publi static final TcpConnectionSimulatort3_fiber= newTcpConnectionSimulator( 45000, /* Kbps*/ 10, /* millisecslatency*/ 0, /* jitter */ 0 /* packet loss % */); publistaticfinalTcpConnectionSimulatorcell= newTcpConnectionSimulator( 100, /* Kbps */ 400, /* millisecs latency */ 250, /* jitter */ 5 /* packet loss % */); } 他のインスタンスに合わせ る,改行をいれることで一貫 性を実現 コメントの整列
  5. “Doug Adams“のようなpartical_nameを”Mr.Douglas Adams”に変換する(出来なかったらエ ラー文を返す)関数のテスト assert(expandFullName($databaseConnection, "Doug Adams", $error) =="Mr. Douglas

    Adams"); assert($error ==""); assert(expandFullName($databaseConnection, " Jake Brown ", $error) =="Mr. Jacob Brown III"); assert($error ==""); assert(expandFullName($databaseConnection, "No Such Guy", $error) ==""); assert($error =="No match found."); assert(expandFullName($databaseConnection, "John", $error) ==""); assert($error =="More than one result.");
  6. “Doug Adams“のようなpartical_nameを”Mr.Douglas Adams”に変換する(出来なかったらエ ラー文を返す)関数のテスト assert(expandFullName(&databaseConnection, "Doug Adams", &error) =="Mr. Douglas

    Adams"); assert($error ==""); assert(expandFullName(&databaseConnection, " Jake Brown ", &error) =="Mr. Jacob Brown III"); assert($error ==""); assert(expandFullName(&databaseConnection, "No Such Guy",&$error) ==""); assert($error =="No match found."); assert(expandFullName(&databaseConnection, "John", &error) ==""); assert($error =="More than one result."); シルエットが不格好 一貫性のあるパターンがな い
  7. “Doug Adams“のようなpartical_nameを”Mr.Douglas Adams”に変換する(出来なかったらエ ラー文を返す)関数のテスト assert(expandFullName(databaseConnection, "Doug Adams", $error) =="Mr. Douglas

    Adams"); assert($error ==""); assert(expandFullName(databaseConnection, " Jake Brown ", $error) =="Mr. Jacob Brown III"); assert($error ==""); assert(expandFullName(databaseConnection, "No Such Guy", $error) ==""); assert($error =="No match found."); assert(expandFullName(databaseConnection, "John", $error) ==""); assert($error =="More than one result."); シルエットが不格好 一貫性のあるパターンがな い
  8. “Doug Adams“のようなpartical_nameを”Mr.Douglas Adams”に変換する(出来なかったらエ ラー文を返す)関数のテスト assert(expandFullName(databaseConnection, "Doug Adams", &error) =="Mr. Douglas

    Adams"); assert($error ==""); assert(expandFullName(databaseConnection, " Jake Brown ", &error) =="Mr. Jacob Brown III"); assert($error ==""); assert(expandFullName(databaseConnection, "No Such Guy", &error) ==""); assert($error =="No match found."); assert(expandFullName(databaseConnection, "John", &error) ==""); assert($error =="More than one result."); 重複している文字列が邪魔なのでヘルパーメソッドを使う必要がある シルエットが不格好 一貫性のあるパターンがな い
  9. checkFullName("DougAdams", "Mr. Douglas Adams", ""); checkFullName(" JakeBrown ", "Mr.JacobBrownIII", "");

    checkFullName("NoSuchGuy", "", "Nomatchfound."); checkFullName("John", "", "More than oneresult."); void checkFullName(string partialName, string expectedFullName, string expectedError) { string error = ''; string fullName=expandFullName(database_connection,partialName,&error); assert(fullName == expectedFullName); assert(error == expectedError)); } 4つのテストがあることがわ かりやすい 重複を排除したことでコード が簡潔に テストの追加が簡単
  10. checkFullName("DougAdams", "Mr. Douglas Adams", ""); checkFullName(" JakeBrown ", "Mr.JacobBrownIII", "");

    checkFullName("NoSuchGuy", "", "Nomatchfound."); checkFullName("John", "", "More than oneresult."); void checkFullName(string partialName, string expectedFullName, string expectedError) { string error = ''; string fullName=expandFullName(database_connection,partialName,&error); assert(fullName == expectedFullName); assert(error == expectedError)); } コードの見た目を美しくしたことによって表面上の解決だけでなく コードの構造も改善できる 4つのテストがあることがわ かりやすい 重複を排除したことでコード が簡潔に テストの追加が簡単
  11. checkFullName("DougAdams", "Mr. Douglas Adams", ""); checkFullName(" JakeBrown ", "Mr.JacobBrownIII", "");

    checkFullName("NoSuchGuy", "", "Nomatchfound."); checkFullName("John", "", "More than one result.");
  12. checkFullName("DougAdams", "Mr. Douglas Adams", ""); checkFullName(" JakeBrown ", "Mr.JacobBrownIII", "");

    checkFullName("NoSuchGuy", "", "Nomatchfound."); checkFullName("John", "", "More than one result.");             列を整列させる          //particalName ,expectedFullName , expected error checkFullName(“Doug Adams” , "Mr. Douglas Adams", “”); checkFullName(“Jake Brown” , "Mr.JacobBrownIII" , “”); checkFullName(“No Such Guy” , “” , “Nomatchfound.”); checkFullName(“John” , “” , “More than one result.”); 引数がわかりやすい
  13. //POSTのパラメータをローカル変数に割り当てる details = request.POST.get("details"); location = request.POST.get("location"); phone = equest.POST.get("phone");

    email = requesPOST.get("email"); url= request.POST.get("url"); details = request.POST.get("details"); location = request.POST.get("location"); phone = equest.POST.get("phone"); email = requesPOST.get("email"); url = request.POST.get("url"); タイプミスに気付きやすい
  14. details = request.POST.get("details"); location = request.POST.get("location"); phone = request.POST.get("phone"); email

    = request.POST.get("email"); url = request.POST.get("url"); ”意味のある順番”に並べるとgood 入力フォームと同じ並び順にする 「最重要」なものから重要度順に並べる アルファベット順に並べる... and 順番は一連のコードの中で共通させるべき
  15. class FrontendServer { public : FrontendServer(); void ViewProfile(HttpRequest* request); void

    OpenDatabase(string location, string user); void SaveProfile(HttpRequest* request); string ExtractQueryParam(HttpRequest* request, string param); void ReplyOK(HttpRequest* request, string html); void FindFriends(HttpRequest* request); void ReplyNotFound(HttpRequest* request, string error); void CloseDatabase(string location); ~FrontendServer(); }; フロントサーバ用のクラス メソッドの概要が把握しにく い
  16. class FrontendServer { public : FrontendServer(); ~FrontendServer(); //ハンドラ void ViewProfile(HttpRequest*

    request); void SaveProfile(HttpRequest* request); void FindFriends(HttpRequest* request); //リクエストとリプライのユーティリティ string ExtractQueryParam(HttpRequest* request, string param); void ReplyOK(HttpRequest* request, string html); void ReplyNotFound(HttpRequest* request, string error); //データベースのヘルパー void OpenDatabase(string location, string user); void CloseDatabase(string location); }; グループに分けたことで概要 把握が簡単に
  17. //ユーザのメール帳をインポートして、システムのユーザと照合する。 //そして、まだ友達になっていないユーザのメールアドレスを取得する。 def suggest_new_friends(user,email_password){ friends = user.friends(); friends_emails= set(f.email for

    f in friends) contacts = import_contacts(user.email, email_password) contacts_emails = set(c.emails for c in contacts) non_friend_emails = contact_emails - friends_emails suggested_friends = User.objects.select(email_in=non_friend_emails) display[‘user’] = user display[‘friends’] = friends display[‘suggested_friends’] = suggested_friends return render(“suggested_friends.html”,display) } 一塊になっていて読みにくい
  18. //ユーザのメール帳をインポートして、システムのユーザと照合する。 //そして、まだ友達になっていないユーザのメールアドレスを取得する。 def suggest_new_friends(user,email_password) { //ユーザの友達のメールアドレスを取得する friends = user.friends(); friends_emails=

    set(f.email for f in friends) //ユーザのメールアカウントから全てのメールアドレスをインポートする contacts = import_contacts(user.email, email_password) contacts_emails = set(c.emails for c in contacts) //まだ友達になっていないユーザを探す non_friend_emails = contact_emails - friends_emails suggested_friends = User.objects.select(email_in=non_friend_emails) //ページに表示する display[‘user’] = user display[‘friends’] = friends display[‘suggested_friends’] = suggested_friends return render(“suggested_friends.html”,display) } 手順ごとに段落に分割する ことで概要がつかめるように
  19. class Logger { … }; class = Logger { …

    }; どちらの表記も間違いはない & 読みやすさには影響しない but... スタイルを混ぜることは推奨されない “一貫性”が最重要
  20. Slide title Dummy text: A wonderful serenity has taken possession

    of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. ✅ Here are the bullet. ✅ List items here. ✅ Write a concept such as the slide.
  21. Slide title Your text here. Dummy text: A wonderful serenity

    has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents.
  22. Slide title Your text here. Dummy text: A wonderful serenity

    has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.I am alone, and feel the charm of existence in this spot, which was created for the bliss of souls like mine. I am so happy, my dear friend, so absorbed in the exquisite sense of mere tranquil existence, that I neglect my talents. *Memo : - Dummy text, I enjoy with my whole heart.I am alone, and feel the charm of existence in this spot, - which was created for the bliss of souls like mine.
  23. Slide title Your text here. Dummy text: A wonderful serenity

    has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.
  24. Content A Your text here. Dummy text: A wonderful serenity

    has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. Content B Your text here. Dummy text: A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.
  25. Content A Your text here. Dummy text: A wonderful serenity

    has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. Content B Your text here. Dummy text: A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart. Content C Your text here. Dummy text: A wonderful serenity has taken possession of my entire soul, like these sweet mornings of spring which I enjoy with my whole heart.
  26. Slide title You can copy & paste graphs from Google

    Spreadsheet of Excel. グラフは Google スプレッドシートやExcel からコピーして貼り付けることができます。
  27. Slide title Step 1. Write the first step here. Step

    2. Write the second step here. Step 3. Write the third step here.
  28. Readme ✅ Theme by Template Park. >https://template-parks.com/ ✅ 商用利用が可能です。 ✅

    ダウンロードした本人の使用のみ可能です。 ✅ 再配布・転売等は禁止しております。 ✅ その他、ご利用規約とプライバシポリシーもご確認ください。 ✅ テンプレートを気に入って頂きましたら、ぜひシェアして頂けると嬉しいです。新し いテンプレート作成の励みになります。 ★ 画像の変更(差し替え)方法は“こちらの解説ページ”をご覧ください。