Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

David Bernstein : Five Development Practices fo...

David Bernstein : Five Development Practices for Building Software with Scrum

Avatar for Yasunobu Kawaguchi

Yasunobu Kawaguchi PRO

January 11, 2023
Tweet

More Decks by Yasunobu Kawaguchi

Other Decks in Technology

Transcript

  1. Integrate Continuously David Bernstein – To Be Agile (http://ToBeAgile.com) http://ToBeAgile.com

    [email protected] © Copyright 2022 To Be Agile DB20221109 Five Development Practices for Building Software with Scrum スクラムで゜フトりェアを構築するための 5 ぀の開発プラクティス
  2. 2 David Scott Bernstein  Software developer since 1980 

    Trained 10,000 developers since 1990  Author of the book Beyond Legacy Code: Nine Practices to Extend the Life (and Value) of Your Software Website: http://ToBeAgile.com Twitter: @ToBeAgile デビッドスコットバヌンスタむン
  3. 3 David Scott Bernstein  1980幎から゜フトりェア開発者  1990幎から10,000人の開発者を育成  「Beyond

    Legacy Code Nine Practices to Extend the Life (and Value) of Your Software 」(邊蚳:レガシヌコヌドから の脱华) の著者 Website: http://ToBeAgile.com Twitter: @ToBeAgile デビッドスコットバヌンスタむン
  4. 4 Book – Beyond Legacy Code http://ToBeAgile.com [email protected] http://BeyondLegacyCode.com 

    Nine practices to design and build healthy code, plus some tips on dealing with legacy code.  Discusses the value and reasoning behind the technical practices, so both managers and the team can get on the same page as to their value.  It’s not a “How To” book, it’s a “Why To” book. 本レガシヌコヌドからの脱华
  5. 5 Book – Beyond Legacy Code http://ToBeAgile.com [email protected] http://BeyondLegacyCode.com 

    健党なコヌドを蚭蚈・構築する ための9぀のプラクティスず、レ ガシヌコヌドを扱う際のヒント を玹介したす。  技術的プラクティスの䟡倀ずそ の理由を説明するこずで、マネ ヌゞャヌずチヌムが同じレベル で話し合うこずができるように なりたす。  「How To」ではなく、「Why To 」の本です。 本レガシヌコヌドからの脱华
  6. 6 Some Questions for You • How many of your

    teams are doing Scrum? • More than a year? Two? Five? Seven? • How many of your teams are doing XP? • More than a year? Two? Five? Seven? • Which technical practices? • CI, TDD, refactoring, pairing? “This book shows readers how to use SCRUM, an Agile software development process, to quickly and seamlessly implement XP in their shop-while still producing actual software. Using SCRUM and the Agile process can virtually eliminate all downtime during an XP implementation.” “Agile Software Development with Scrum” -- Ken Schwaber and Mike Beedle ? あなたぞの質問
  7. 7 Some Questions for You • あなたのチヌムはスクラムをどれくらい やっおいたすか • 1幎以䞊ですか2幎5幎7幎

    • XPはどれくらいやっおいたすか • 1幎以䞊ですか2幎5幎7幎 • 技術プラクティスはどれを • CI、TDD、リファクタリング、ペアリン グ 「本曞は、読者が実際の゜フトりェアを生産しながら、 SCRUMずアゞャむル゜フトりェア開発プロセスを䜿甚しお、 XPを玠早くシヌムレスに導入する方法を玹介したす。 SCRUMずアゞャむルプロセスを䜿うこずで、 XP導入時のダりンタむムを実質的にすべおなくすこずができたす。」 Agile Software Development with Scrum” -- Ken Schwaber and Mike Beedle ? あなたぞの質問
  8. 8 1. Say What, Why, and for Whom before How:

    With a Product Owner defining the next most important features to build, the need for upfront requirements goes away. 2. Build in Small Batches: Building incrementally increases feedback, helps simplify the construction of complex systems, and reduces risks. 3. Integrate Continuously: Sets up the infrastructure for incremental development. 4. Collaborate: Pairing, mobbing, spiking, and swarming as a team to solve problems and radiate knowledge throughout an organization. 5. Create CLEAN Code: Share standards and practices for building software with code qualities that support testability. 6. Write the Test First: Drops the cost of building and maintaining software dramatically. 7. Specify Behaviors with Tests: Uses tests to define and document behaviors. 8. Implement the Design Last: Paying technical debt can pay back dividends in the short term as well as the long term. 9. Refactor Legacy Code: Incorporate learning and pay off technical debt. Nine Essential Practices ぀の基本プラクティス
  9. 9 1. やり方より先に目的、理由、誰のためかを䌝える。プロダクトオヌナヌが次に䜜るべき最も重 芁な機胜を定矩するこずで、芁求を事前に揃えおおく必芁性をなくしたす。 2. 小さなバッチで䜜る。段階的に構築するこずで、フィヌドバックが増え、耇雑なシステムの構 築を簡玠化し、リスクを䜎枛するこずができたす。 3. 継続的に統合する。むンクリメンタルな開発のためのむンフラストラクチャを構築したす。 4.

    協力しあう。ペアリング、モビング、スパむク、スりォヌミングなど、チヌムずしお問題解決 に取り組み、組織党䜓に知識を広めたす。 5. 「CLEAN」なコヌドを䜜る。゜フトりェアを構築する暙準ずプラクティスを共有したす。テ ストしやすい高品質なコヌドを生み出したす。 6. たずテストを曞く。゜フトりェアの構築ず維持にかかるコストを劇的に削枛したす。 7. テストふるたいを明瀺する。テストを甚いお振る舞いを定矩し、文曞化したす。 8. 蚭蚈は最埌に行う技術的負債の返枈を行えば、長期だけでなく、短気にも利益を埗るこずが できたす。 9. レガシヌコヌドをリファクタリングする。孊習を取り入れ、技術的負債を返枈したす。 Nine Essential Practices ぀の基本プラクティス
  10. 10 Practice 3 - Integrate Continuously  Integration can be

    painful so teams put it off to the end of a project. A better alternative is to integrate continuously, whenever even the smallest bit of functionality is added to the system.  I have a friend who works in an XP shop and I remember when he took me on a tour after hours. He said, “Let me show you what happens if someone breaks the build.” He typed a few lines at the console and suddenly all the florescent lights on the floor when out and a red light started flashing and sirens went off.  He said, ”This is what happens when you break the build. We don’t allow broken builds in this shop.” That’s how ingrained a working build is in their culture. プラクティス3 - 継続的に統合する
  11. 11 Practice 3 - Integrate Continuously  統合は倧倉な䜜業であるため、プロゞェクト終了たで先延ばしに しおしたうチヌムがありたす。よりよい方法は、システムに少し でも機胜が远加されるたびに、継続的に統合するこずです。

     私の友人にXPの職堎で働いおいる人がいるのですが、営業時間倖 に私を案内しおくれたずきのこずを思い出したす。 「誰かがビルドを壊したらどうなるか芋せおあげようか」。圌が コン゜ヌルで数行タむプするず、突然フロアの蛍光灯がすべお消 え、赀いランプが点滅し始め、サむレンが鳎り響いたんです。  「ビルドを壊すずこうなるんだ。ここでは壊れたビルドは蚱さな いんだ 」ず圌は蚀いたした。圌らの文化には、ビルドが通っおい るこずの重芁性がそれほど根付いおいたした。 プラクティス3 - 継続的に統合する
  12. 12 The Heartbeat of a Project  Doing CI changes

    the dynamic of development. You always have a buildable system so you know exactly where you stand.  When developers get instant feedback if something they did during the last few minutes caused a defect then they can quickly and easily back out those changes.  But when a simple little defect goes unnoticed for days or even weeks then it can take hours, if not days to track down and fix.  We can use the feedback from continuous integration to gain valuable insights into improving how we code.  Once set up, continuous integration becomes a source of rich feedback for developers. プロゞェクトのハヌトビヌト(錓動)
  13. 13 The Heartbeat of a Project  CIを行うこずで、開発のダむナミズムが倉わりたす。ビルド可胜なシステム が垞にあるので、自分の立ち䜍眮を正確に把握するこずができたす。 

    数分前に行ったこずが原因で䞍具合が発生した堎合、開発者はすぐにフィヌ ドバックを埗るこずができ、玠早く簡単にその倉曎を取り消すこずができた す。  しかし、シンプルで小さな䞍具合でも䜕日も䜕週間も気づかれないたたにな るず、远跡しお修正するのに䜕時間も、いや䜕日もかかるこずになりたす。  継続的むンテグレヌションからのフィヌドバックは、私たちのコヌディング 方法を改善するための貎重な掞察を埗るために䜿甚するこずができたす。  䞀床セットアップすれば、継続的むンテグレヌションは開発者にずっお豊富 なフィヌドバックの源ずなりたす。 プロゞェクトのハヌトビヌト(錓動)
  14. 14 Three Kinds of Done  Here are three definitions

    of done: – Done: The developer who wrote the feature got it to work on their computer. – Done-Done: The feature is integrated into the build and is working. – Done-Done-Done: The feature is integrated into the build, is cleaned up and made supportable.  We want to strive to get each feature to done-done-done as soon as possible so we get faster feedback and have less work-in- progress. Done(完成)には䞉皮類ある
  15. 15 Three Kinds of Done  ここでは、Done(完成)の定矩を3぀玹介したす。 – Done: その機胜を曞いた開発者の、自分のコンピュヌタで動䜜する。

    – Done-Done: その機胜はビルドに統合され、動䜜しおいる。 – Done-Done-Done: その機胜はビルドに統合され、クリヌンアップさ れお、保守可胜になっおいる。  私たちは、各機胜をできるだけ早くDone-Done-Doneにするよう 努力し、より迅速なフィヌドバックを埗お、仕掛かり品を少なく したいず考えおいたす。 Done(完成)には䞉皮類ある
  16. 16 Continuous Deployability  Continuous deployability doesn’t mean we continuously

    deploy. It means you can deploy whenever you want to.  When you deploy is a business decision based on product cycles, maintenance contracts, etc. Continuous deployability means you could deploy at any time that the business desires.  This drops the risk of building features because you can see each feature integrated into the system and it gives developers feedback as they build features.  Make sure you version everything your build depends on including build scripts, stored procedures, database layouts, etc. 継続的にデプロむ可胜であるこず
  17. 17 Continuous Deployability  継続的デリバリヌは、継続的にデプロむするずいう意味ではあり たせん。い぀でも奜きなずきにデプロむできるずいう意味です。  い぀デプロむするかは、補品サむクルや保守契玄などに基づいお ビゞネス䞊の決定がなされたす。継続的なデプロむが可胜ずいう こずは、ビゞネスが望むタむミングでデプロむできるずいうこず

    です。  システムに統合された各機胜を芋るこずができ、開発者が機胜を 構築する際にフィヌドバックを埗られるため、機胜構築のリスク を䜎枛するこずができたす。  ビルドスクリプト、ストアドプロシヌゞャ、デヌタベヌスレむア りトなど、ビルドが䟝存するものすべおをバヌゞョンアップする ようにしたしょう。 継続的にデプロむできる状態
  18. 18 Automate the Build  Make sure the build runs

    fast (within a few seconds) and is easy to invoke (with a single click).  Slow tests are the main reason for slow builds. Speed up tests by only testing what’s needed and mocking out dependencies.  Your build will reveal your dependencies and whether you have a good architecture or not.  If the build breaks, then fix it immediately. ビルドを自動化する
  19. 19 Automate the Build  ビルドが高速に数秒以内に実行され、簡単にワンクリック で起動できるこずを確認しおください。  ビルドが遅くなる䞻な原因は、テストの遅さです。必芁なものだ けをテストし、䟝存関係をモック化するこずで、テストを高速化

    したしょう。  ビルドによっお、䟝存関係や良いアヌキテクチャを持っおいるか どうかが明らかになりたす。  もしビルドが壊れたら、すぐに修正したしょう。 ビルドを自動化する
  20. 20 Integrate Early and Often  We want to integrate

    code all the time, several times a day.  Integrating each little bit of functionality as it is written to be sure the code works with the rest of the system.  Being able to prove the system is still working with the click of a button is like a shot of espresso, it energizes me. 早めに、頻繁に統合する
  21. 21 Integrate Early and Often  私たちは、コヌドを垞に、䞀日に䜕床も統合したいず考えおいた す。  少しず぀機胜を統合しおいきたす。曞かれたコヌドが意図通り、

    システムの他の郚分ず連動するこずを確認したす。  ボタンを䞀぀クリックするだけで、システムが今も機胜しおいる こずを蚌明できる。このこずは、䞀杯の゚スプレッ゜のように、 私に掻力を䞎えおくれたす。 早めに、頻繁に統合する
  22. 22 Take the First Step  Continuous integration is the

    most valuable practice for building software and is often an easy practice to implement.  Continuous integration provides the infrastructure for the other technical practices. It may take some work up front to set up but it pays for itself many times over during the life of a project.  For a lot of teams, CD is the next most valuable step. Even teams that are doing it can do it better, and by better I mean integrate more frequently.  I know developers who run their local build every 20 seconds when developing. That’s a huge amount of feedback they get.  --- 最初の䞀歩を螏み出す
  23. 23 Take the First Step  継続的むンテグレヌションは、゜フトりェアを構築する䞊で最も䟡倀 のあるプラクティスであり、倚くの堎合、簡単に実斜できるプラクテ ィスです。 

    継続的むンテグレヌションは、他の技術的実践のためのむンフラスト ラクチャを提䟛したす。セットアップに倚少の手間がかかるかもしれ たせんが、プロゞェクトの期間䞭に䜕床も元を取るこずができたす。  倚くのチヌムにずっお、最も䟡倀がある次のステップは継続的デリバ リヌ(CD) です。CDをすでに行っおいるチヌムも、さらに良くするこ ずができたす。もっず頻繁に統合するのです。  私の知り合いの開発者は、開発しながら20秒ごずにロヌカルビルドを 実行したす。これにより膚倧な量のフィヌドバックを埗おいたす。 最初の䞀歩を螏み出す
  24. 24 Practice 4 - Collaborate  Collaboration doesn’t always just

    happen. It requires skills and the right environment to flourish. We can set ourselves up for successful collaboration by learning these skills.  We can learn from each other and there’re techniques we can use to help us.  When I was a contractor at IBM, we were thrown into a big room with desks smashed up against each other. They called it the “bull pen.” IBM Employees got their own offices but they were always amazed at how much we got done. This was partly due to working so closely together. プラクティス4 - コラボレヌション
  25. 25 Practice 4 - Collaborate  コラボレヌションは垞に起こるものではありたせん。コラボレヌ ションを成功させるにはスキルず適切な環境が必芁です。私たち はこれらのスキルを身に぀けるこずで、コラボレヌションを成功 させるための準備をするこずができたす。

     私たちはお互いから孊ぶこずができたすし、そのために䜿えるテ クニックもありたす。  私がIBMで契玄瀟員だったころ、私たちは倧きな郚屋に攟り蟌た れ、机を互いにぶ぀け合っおいたした。それを “ブルペン ”ず呌ん でいたした。IBMの瀟員は自分のオフィス(郚屋)を持っおいたした が、私たちの仕事ぶりにはい぀も驚かされおいたした。その理由 は、私たちは密接に連携しおいたからです。 プラクティス4 - コラボレヌション
  26. 26 Extreme Programming  Kent Beck along with Ward Cunningham

    and Ron Jeffries developed Extreme Programming while working on the Chrysler Comprehensive Compensation System.  Notice how the work area in the photo is open with lots of whiteboard space on the walls and pairing stations at every computer.  Isolating people in offices may not be the best way to encourage collaboration. Open workspaces work well.  Menlo Innovations converted a parking garage into a large open workspace where several development teams can work together ゚クストリヌムプログラミング
  27. 27 Extreme Programming  ケント・ベックは、りォヌド・カニンガム、ロン・ゞェフリヌズ ずずもに、クラむスラヌの包括的補償システムに取り組んでいた ずきに゚クストリヌムプログラミングを開発したした。  この写真のワヌク゚リアはオヌプンで、壁にはたくさんのホワむ トボヌドスペヌスがあり、各コンピュヌタヌにはペアリング・ス

    テヌションが蚭眮されおいるこずに泚目しおください。  オフィスの䞭で人を孀立させるこずはコラボレヌションを促進す る最善の方法ではないかもしれたせん。オヌプンなワヌクスペヌ スは効果的です。  メンロヌむノベヌションズは駐車堎を改造し、耇数の開発チヌム が䞀緒に仕事ができるように倧きなオヌプンワヌクスペヌスにし たした。 ゚クストリヌムプログラミング
  28. 28 Communicate and Collaborate  Enterprise software development is a

    social activity.  We must have a shared understanding of our goals and approaches to developing software. We must have a shared definition of “quality” and of when we will be “done.”  Developing software is a collaborative act.  People say us nerds are bad communicators. I disagree. We may not always like small talk but we love high-bandwidth communication and we’re good at it, it’s part of our job. コミュニケヌションずコラボレヌション
  29. 29 Communicate and Collaborate  䌁業の゜フトりェア開発は、瀟䌚掻動です。  私たちは、゜フトりェア開発の目暙ずアプロヌチに぀いお、共通 の理解を持っおいなければなりたせん。私たちは、「品質」ず「 い぀終わるか」に぀いお、共通の定矩を持っおいなければなりた

    せん。  ゜フトりェアを開発するこずは、協調䜜業です。  私たちオタクはコミュニケヌションが䞋手だず蚀われたすが、私 はそう思いたせん。私たちはちょっずした雑談は奜きではないか もしれたせんが、広垯域の(情報量の倚い)コミュニケヌションは 倧奜きです。それが私たちの仕事です。 コミュニケヌションずコラボレヌション
  30. 30 Pair Program  Pair programming is one of the

    most valuable practices that I get the most resistance from both managers and developers. Managers tell me they don’t want to loose half their “resources” but pair programming isn’t taking turns at the computer, it’s bringing two minds to bare on tough problems.  When pairing, problems are solved faster, with less code, fewer errors, and costs only 15% more dev time. Pairing is the fastest way to propagate skills across a team. People who pair are less likely to be interrupted, stay on task, support each other in doing the right things, and are constantly learning.  When I finish a day of pairing I’m exhausted yet supremely satisfied. And this is why you managers should support it. ペアプログラミング
  31. 31 Pair Program  ペアプログラミングは、最も䟡倀のあるプラクティスのひず぀ですが、 私はマネヌゞャヌず開発者の䞡方から最も抵抗を受けおいたす。しかし 、ペアプログラミングずは、コンピュヌタを亀代で䜿うこずではなく、2 ぀の頭脳を駆䜿しお難問に取り組むこずなのです。  ペアを組めば、問題はより早く、より少ないコヌドで、より少ない゚ラ

    ヌで解決され、開発時間は15増で枈みたす。ペアリングは、チヌム党 䜓にスキルを浞透させる最速の方法です。ペアリングをする人は、䞭断 されるこずが少なく、タスクに集䞭し、正しいこずをするためにお互い をサポヌトし合い、垞に孊習しおいるのです。  私はペアリングの䞀日を終えるず、疲れながらも最高の満足感を味わう こずができたす。だからこそ、マネヌゞャヌはペアリングを支持すべき なのです。 ペアプログラミング
  32. 32 Buddy Program  Successful pair programming requires special skills.

    The driver is at the keyboard, the navigator is thinking about what’s next.  Pair randomly with everyone on the team. Switch driver and navigator every 5-20 minutes or when the other person is bored.  Sometimes I can’t convince a team to try pairing so I suggest buddy programming. Buddy programming is less extreme than pair programming.  In buddy programming, developers work alone for most of the day then get together with their “buddy” for the last hour of the day to code review the day’s work. As with pairing, it’s good to mix it up and have a different buddy daily, at each iteration, etc. バディ・プログラミング
  33. 33 Buddy Program  ペアプログラミングを成功させるには、特別なスキルが必芁です。ドラ むバヌはキヌボヌドに向かい、ナビゲヌタヌは次を考えあす。  チヌムの党員ずランダムにペアを組みたす。5〜20分おきに、あるいは盞 手が飜きたら、ドラむバヌずナビゲヌタヌを亀代したす。 

    ペアを組むこずに玍埗できないチヌムには、バディ・プログラミングを 提案するこずもありたす。バディプログラミングは、ペアプログラミン グほど゚クストリヌム極端ではありたせん。  バディプログラミングでは、開発者は䞀日の倧半を䞀人で䜜業し、最埌 の䞀時間に「バディ」ず䞀緒にその日の䜜業をコヌドレビュヌしたす。 ペアリングず同じように、毎日、むテレヌションごずに異なるバディを 持぀など、混ぜ合わせるずよいでしょう。 バディ・プログラミング
  34. 34 Spike, Swarm, and Mob  Spiking is when one

    or a few people research unknowns in a fixed time box, usually to answer specific questions.  Swarming is when the whole team works together to solve the same problem.  Mobbing is when the whole team works together on the same story.  This is a still from a video you can watch at MobProgramming.org where an 8-hour workday of a team mobbing is compressed down to 5 minutes. You’ll see everyone engaged the whole day. They made great progress on certain kinds of task with mobbing. スパむク、スりォヌム、モブ
  35. 35 Spike, Swarm, and Mob  スパむクずは、1人たたは数人の人が、特定の質問に答えるために 、䞀定の時間枠の䞭で未知のものを研究するこずです。  スりォヌミングは、チヌム党䜓が同じ問題を解決するために協力

    するこずです。  モビングは、チヌム党䜓が同じストヌリヌに取り組むこずです。  これはMobProgramming.orgで芋るこずができるビデオの静止画 で、1日8時間働くチヌムのモビングを5分に圧瞮したものです。 䞀日䞭、みんなが倢䞭になっおいるのがわかりたす。圌らは、あ る皮のタスクに぀いお、モビングで倧きな進歩を遂げたした。 スパむク、スりォヌム、モブ
  36. 36 Time Box Unknowns  When researching unknowns, try to

    phrase questions so they clearly identify what is known from what is unknown. Do this by: – For a specific period of time (an hour, day, week, etc.), research answers to your questions.  At the end of the time box, reassess your goals. Did you get answers to your questions? Do you have new questions? Do you need another time box?  This approach helps you shrink the unknown into the known or, at the very least, you can encapsulate what you don’t know so you can easily deal with it later. 未知のものを調べるタむムボックス
  37. 37 Time Box Unknowns  未知のものを調べるずき、既知のものず未知のものを明確に区別 できるような質問を考えたしょう。そしお、次の䜜業をしたす: – ある䞀定の期間1時間、1日、1週間など、質問の答えを調べる 

    タむムボックスが終了したら、自分の目暙を再確認したしょう。 質問の答えは埗られたしたか新たな質問が湧いおきたしたか さらに別のタむムボックスが必芁でしょうか  この方法は、未知のものを既知のものぞず畳み蟌むのに圹立ちた すし、少なくずも、未知のものをカプセル化しお、埌で察凊しや すくできたす。 未知のものを調べるタむムボックス
  38. 38 Code Reviews, Retrospectives  Code reviews are still important,

    even if you do pair programming.  Code reviews let the rest of the team see your code.  Focus on describing the reasoning for your design choices rather than just saying what you’re doing.  Retrospect regularly to gather feedback and find ways of improving. It’s better to make many small improvements throughout the year than to try to make a lot of big improvements at once. コヌドレビュヌ、レトロスペクティブ
  39. 39 Code Reviews, Retrospectives  コヌドレビュヌは重芁です。たずえペアプログラミングをしおい おも。  コヌドレビュヌでは、チヌムの他のメンバヌがあなたのコヌドを 芋るこずができたす。

     ただやっおいるこずを語るのではなく、蚭蚈䞊の遞択、その理由 を説明するこずに泚力したしょう。  定期的にふりかえりを行い、フィヌドバックを集め、改善策をみ ぀けたす。䞀床に倧きな改善をするよりも、1幎を通しお小さな改 善を積み重ねおいくほうがよいでしょう。 コヌドレビュヌ、レトロスペクティブ
  40. 40 Amplify Learning  The best workers are ones who

    help others. That’s job security today, not by having specialized knowledge.  Team members should be cross-functional.  Teams should practice collective code ownership so everyone can work on any part of the code.  Pairing and mobbing are the most effective ways of propagating new skills across a team. 孊びを増やす
  41. 42 Be Mentoring and Mentored  My mentor, Scott Bain,

    says. “Always strive to be mentoring someone and to be mentored by someone.”  As a teacher myself for over nearly half a century I can say that teaching is one of the best way to learn.  The most successful teams I know have pairing at the core of their culture and take time to know what everyone is doing. メンタリングし、メンタリングを受ける
  42. 43 Be Mentoring and Mentored  私のメンタヌであるスコット・ベむンはこう蚀っおいたす。"垞に 誰かを指導し、誰かから指導されるように努力しなさい"。  私自身、玄半䞖玀以䞊にわたっお教垫をしおきたので、教えるこ

    ずは孊ぶための最良の方法の䞀぀であるず蚀えたす。  私が知る限り、最も成功しおいるチヌムは、ペアリングを文化の 䞭栞に据え、党員が䜕をしおいるかを知るために時間をかけおい たす。 メンタリングし、メンタリングを受ける
  43. 44 Practice 5 – Create CLEAN Code  We can

    infer good development principles and practices through five key code qualities: – Cohesive – Loosely Coupled – Encapsulated – Assertive – Nonredundant  These five code qualities and their relationship to testability underlie all good developer principles and practices. We can infer the right things to do from these five qualities. プラクティス5 – CLEANなコヌドを曞く
  44. 45 Practice 5 – Create CLEAN Code  私たちは、5぀の䞻芁なコヌドの品質を通じお、優れた開発原則ず 実践を掚し量るこずができたす。

    – 凝集性が高い – 疎結合である – カプセル化されおいる – 断定的(アサヌティブ)である – 冗長性がない  この5぀のコヌドの品質ずテスト容易性の関係は、すべおの優れた 開発者の原則ず実践の根底にありたす。私たちは、この5぀の品質 から、正しいこずを掚枬するこずができたす。 プラクティス5 – CLEANなコヌドを曞く
  45. 46 Quality Code is Cohesive  High quality code is

    cohesive, meaning it’s about one thing.  Cohesive classes and method follow the Single Responsibility Principle and have only one reason to exist and therefore one reason to change.  As my esteemed colleague Dr. Daniel Rawsthorne says, “No schizophrenic classes.” Al Shallow says, “No God objects.” Scott Bain says, “Keep entities single-minded.”  So then how do we model complex things? The answer is to compose complex classes from simple classes. 高品質なコヌドは凝集性が高い
  46. 47 Quality Code is Cohesive  高品質なコヌドは凝集性がありたす。぀たり、1぀のこずに぀いお曞かれ おいるのです。  凝集性のあるクラスずメ゜ッドは単䞀責任原則に埓い、存圚する理由は

    ただ䞀぀であり、したがっお倉曎する理由もただ䞀぀です。  私の尊敬するDaniel Rawsthorne博士が蚀うように、「分裂病的なクラス はない」のです。アル・シャロりェむは、「神オブゞェクトはなしで」 ず蚀っおいたす。スコット・ベむンは、「゚ンティティを単䞀化せよ 」 ず蚀っおいたす。  では、耇雑なものをどのようにモデル化すればよいでしょうかその答 えは、単玔なクラスから耇雑なクラスを構成するこずです。 高品質なコヌドは凝集性が高い
  47. 48 Quality Code is Loosely Coupled  We’re not striving

    for no coupling in a system. A system with no coupling is a system that does nothing. We want coupling were we intend it to be and no coupling where we don’t intend it to be.  For this reason, I prefer the terms: intentional versus accidental coupling instead of the terms loose coupling versus tight coupling.  High quality code is intentionally coupled so it doesn’t call concrete classes directly. Coupling through abstractions makes code easier to test now and extend later. Keep all external dependencies loosely coupled.  Coupling is a “second-order effect” so poor coupling is a sign that the other code qualities are missing. 高品質なコヌドは疎結合である
  48. 49 Quality Code is Loosely Coupled  私たちは、システムの無結合化を目指しおいるわけではありたせん。結 合のないシステムは䜕もしないシステムです。私たちは、意図的な結合 は必芁であり、意図しない結合は必芁ないのです。

     このため、私は、匱い結合ず匷い結合ずいう甚語ではなく、意図的な結 合ず䞍慮の結合ずいう甚語を奜んで䜿甚したす。  高品質のコヌドは意図的に結合され、具象クラスを盎接呌び出すこずは ありたせん。抜象化によっお結合するこずで、コヌドを今テストし、埌 で拡匵するこずが容易になりたす。倖郚ずの䟝存関係はすべお疎結合に したす。  結合は「二次的効果」であり、結合が悪いずいうこずは、他のコヌド品 質が欠けおいるこずの衚れです。 高品質なコヌドは疎結合である
  49. 50 Quality Code is Encapsulated  High quality code is

    encapsulated so it’s implementation is hidden. Well-encapsulated code is designed from the outside-in rather than inside-out.  We can encapsulate much more than state and behavior, we can encapsulate sequence, cardinality, selection, etc.  There are many ways to encapsulate things, we can hide an implementation behind an interface, we can hide a concept behind an abstraction. Design patterns encapsulate many different things.  Encapsulation means hiding the how with the what. The art of being a great developer is to hide as much as possible while still getting the job done so you can easily change things later. 高品質なコヌドはカプセル化されおいる
  50. 51 Quality Code is Encapsulated  高品質なコヌドはカプセル化されおいるため、その実装は隠されおいた す。うたくカプセル化されたコヌドは、内偎から倖偎ぞではなく、倖偎 から内偎ぞ蚭蚈されおいたす。 

    状態や振る舞いの他にも、シヌケンス、カヌディナリティ、遞択などを カプセル化するこずができたす。  カプセル化には倚くの方法があり、むンタヌフェむスの埌ろに実装を隠 したり、抜象化の埌ろに抂念を隠したりするこずができたす。デザむン パタヌンは倚くの異なるものをカプセル化したす。  カプセル化ずは、「どのように」を「䜕を」で隠すかずいうこずです。 優れた開発者であるための秘蚣は、仕事を完了させながら、できるだけ 倚くのこずを隠し、埌で簡単に倉曎できるようにするこずです。 高品質なコヌドはカプセル化されおいる
  51. 52 Quality Code is Assertive  High quality code is

    assertive, it manages its own state.  Assertive objects are be in charge of themselves.  Inquisitive objects must query other objects to do their work. This cause rules to be spread out and they become difficult to follow.  Keep responsibilities well defined and remember, he who has the state should have the responsibility. 高品質なコヌドは断定的である
  52. 53 Quality Code is Assertive  高品質のコヌドは断定的であり、自分の状態を自分で管理したす 。  断定的なオブゞェクトは、自分自身を管理するこずができたす。

     奜奇心旺盛なオブゞェクトは、自分の仕事をするために他のオブ ゞェクトを呌び出さなければなりたせん。このため、ルヌルが分 散しおしたい、远いかけるのが難しくなりたす。  責任の所圚を明確にし、「状態を保持するオブゞェクトが責任を 持぀べき」であるこずを忘れないようにしたしょう。 高品質なコヌドは断定的である
  53. 54 Quality Code is Non-Redundant  High quality code is

    nonredundant, it doesn’t repeat itself.  High quality code is nonredundant, it doesn’t repeat itself.  Unintentional redundancy is always a maintenance issue.  Redundancy is far more subtle than just duplication. – Can non-identical code be redundant? Yes, think of a for loop and foreach loop iterating through the same collection. – Can identical code be non-redundant? Yes, think of “index++” accessing a list of names or a list of numbers.  Redundancy is about intent—trying to do the same thing in more than one place. 高品質なコヌドは冗長でない
  54. 55 Quality Code is Non-Redundant  高品質なコヌドは、冗長性がなく、同じこずを繰り返さない。  高品質なコヌドは、冗長性がなく、同じこずを繰り返さない。 

    意図しない冗長性は垞にメンテナンス䞊の問題です。  冗長性は、単なる重耇よりもはるかに埮劙なものです。 – 非同䞀コヌドは冗長になり埗るかはい、forルヌプずforeachルヌプ が同じコレクションを繰り返し凊理するこずを考えおみおください。 – 同じコヌドが冗長でないこずもあるのか名前のリストや数字のリス トにアクセスする「index++」を思い浮かべおください。  冗長性ずは、同じこずを2箇所以䞊で行おうずする意図のこずです 。 高品質なコヌドは冗長でない
  55. 56 Code Qualities Guide Us  When code is cohesive

    it’s easier to read, understand, and find bugs because each entity is dealing with only one thing.  When code is loosely coupled code is more straightforward to test and extend and we see fewer side effects between entities.  When code is encapsulated it reduces the “ripple effect” when changing code and helps us manage complexity.  When code is assertive its data and the code that act on it are together.  When code is nonredundant it means we only have to deal with changing code or fixing bugs in one place. コヌド品質は私たちを導く
  56. 57 Code Qualities Guide Us  コヌドがたずたっおいれば、読みやすく、理解しやすく、バグを 発芋しやすくなりたす。  コヌドが疎結合であれば、テストや拡匵がより簡単になり、゚ン

    ティティ間の副䜜甚も少なくなりたす。  コヌドがカプセル化されおいれば、コヌドを倉曎したずきの「波 及効果」が小さくなり、耇雑さを管理しやすくなりたす。  コヌドが断定的であれば、そのデヌタずそれに䜜甚するコヌドが 䞀緒になっおいたす。  コヌドが冗長でなければ、コヌドの倉曎やバグの修正を䞀箇所で 行うだけでよいこずになりたす。 コヌド品質は私たちを導く
  57. 58 Increase Quality Today
  These code qualities are unlike

    the so called “quality factors” or the “-ables” as I call them. For example, “maintain-able.” If I tell you your software should be maintainable I haven’t helped you much. I haven’t told you how to do what I’ve told you to do.  These qualities are actionable and quantifiable. You can see if a piece of code has them or not and how to improve them.  The only way I know to go fast is to go CLEAN. These code qualities seem simple, almost trivial but when ignored we quickly end up with at “big ball of mud.”  If you want to increase your team’s velocity tomorrow you must increase your code quality today. There are no silver bullets!  今日、 品質を䞊げる
  58. 59 Increase Quality Today
  これらのコヌド品質は、いわゆる「品質芁因」や「-ables」ず呌ばれるも のずは異なりたす。䟋えば、“maintenance-able ”です。もし私が、あなた の゜フトりェアはメンテナンス可胜であるべきだ、ず助蚀したずしおも 、あたり助けにはならないでしょう。どうやっおそれをやるかを教えお

    いないからです。  これらの品質は、実行可胜で定量化可胜です。あるコヌドがこの性質を 備えおいるかどうか、そしおどのように改善すればよいかを知るこずが できるのです。  私が知っおいる高速化する唯䞀の方法は、CLEANにするこずです。これ らのコヌドの品質は単玔で、ほずんど些现なこずのように芋えたすが、 無芖するずすぐに「倧きな泥だんご」になっおしたいたす。  もしあなたが明日、チヌムのベロシティを䞊げたいなら、今日、コヌド の品質を䞊げるこずです。銀の匟䞞はないのです。  今日、 品質を䞊げる
  59. 60 Practice 6 - Write the Test First  Some

    people say TDD is dead because it forces you to write bad code and they’re right but that’s because they’re doing TDD wrong.  “Test-induced damage” comes from writing too many tests and implementation dependent tests that not only “damage” software, they also impedes refactoring.  But when done correctly, TDD helps us write CLEAN code that’s more maintainable. The key is understanding what TDD really is. プラクティス6 – たずテストを曞く
  60. 61 Practice 6 - Write the Test First  TDDは悪いコヌドを曞かせるからダメだず蚀う人がいお、それは

    正しいのですが、それはTDDのやり方を間違えおいるからなので す。  「テストによる損傷」は、゜フトりェアを「損傷」させるだけで なく、リファクタリングの劚げにもなる、倚すぎるテストや実装 䟝存のテストを曞くこずから生じたす。  しかし、正しく行えば、TDDは、より保守性の高いCLEANなコヌ ドを曞くのに圹立ちたす。重芁なのは、TDDが本圓は䜕であるか を理解するこずです。 プラクティス6 – たずテストを曞く
  61. 62 The Things We Call Tests  The word “test”

    represents many things in software development: • Acceptance tests are customer tests, they help clarify the conversation between the customer and developers. • Unit tests are developer tests, they help developers build out features so they’re testable and easy to work with. • Other tests are quality assurance tests, they help verify the software is bug free. • Each of these activities are very different from each other. 私たちがテストず呌んでいるもの
  62. 63 The Things We Call Tests  ゜フトりェア開発においお、「テスト」ずいう蚀葉は様々なこず を衚しおいたす。 –

    受け入れテストは顧客テストであり、顧客ず開発者の間の䌚話を明確 にするのに圹立ちたす。 – ナニットテストは開発者のテストであり、開発者がテスト可胜で䜜業 しやすいように機胜を構築するのを助けたす。 – その他のテストは品質保蚌テストであり、゜フトりェアにバグがない こずを確認するためのものです。  これらの掻動は、それぞれ倧きく異なりたす。 私たちがテストず呌んでいるもの
  63. 64 Quality Assurance  TDD doesn’t replace QA but it

    can help.  There are many kinds of QA testing but for our purposes let’s break it out into two categories: – Release candidate validation – Everything else  Make release candidate validation fully automated so it requires no human intervention. Let QA focus on other kinds of testing. 品質保蚌(QA)
  64. 65 Quality Assurance  TDDはQAに取っお代わるものではありたせんが、助けになるもの です。  QAテストには倚くの皮類がありたすが、ここでは2぀のカテゎリ に分類しお説明したす。 –

    リリヌス候補の怜蚌 – その他すべお  リリヌス候補の怜蚌を完党に自動化し、人間の介入を䞍芁ずした す。QAは他の皮類のテストに集䞭するようにしたしょう。 品質保蚌(QA)
  65. 66 Write Good Tests  People assume they know how

    to write a good test and do TDD effectively but that’s rarely the case.  Think of tests as specifications for the behaviors that you want to create. Make tests unique and only write enough implementation to make your tests pass.  The “units” we test are units of behavior, not units of code. When we refactor to implement our designs, we don’t need to add more tests, the ones we have are sufficient and support us in refactoring. Only when we add new behavior should we add tests. 良いテストを曞く
  66. 67 Write Good Tests  人々は、良いテストの曞き方を知っおいお、効果的にTDDを行う こずができるず思い蟌んでいたすが、そうであるこずはほずんど ありたせん。  テストは、あなたが䜜りたい動䜜の仕様曞だず考えおください。

    テストは重耇のないものにし、テストに合栌するのに十分な実装 だけを曞きたしょう。  テストする「単䜍」は、コヌドの単䜍ではなく、振る舞いの単䜍 です。蚭蚈を実装するためにリファクタリングするずき、テスト を増やす必芁はありたせん。今あるテストで十分であり、リファ クタリングをサポヌトしたす。新しい振る舞いを远加するずきだ け、テストを远加すればいいのです。 良いテストを曞く
  67. 68 TDD Gives Rapid Feedback  The faster bugs are

    found the cheaper they are to fix.  Good tests provide regression that is a constant source of feedback on the system.  When developers run their tests all the time they get rapid feedback on what works and what causes problems. The same issues that could have taken days to find and fix can typically be resolve in a matter of minutes.  When stimulus and response are brought together developers begin to change their habits and write higher quality code.  The top developers I know get feedback about 3 times a minute. TDDは迅速なフィヌドバックを提䟛
  68. 69 TDD Gives Rapid Feedback  バグが早く芋぀かれば芋぀かるほど、その修正コストは安くなりたす。  良いテストはリグレッションを提䟛し、垞にシステムに察するフィヌド バックの源ずなりたす。

     開発者が垞にテストを実行するこずで、䜕が機胜し、䜕が問題を匕き起 こすかに぀いおの迅速なフィヌドバックが埗られたす。䜕日もかけお芋 ぀けた問題を、数分で解決するこずができるのです。  刺激ず反応が䞀緒になったずき、開発者は習慣を倉え、より質の高いコ ヌドを曞くようになりたす。  私が知っおいる䞀流の開発者は、1分間に3回ほどフィヌドバックを受け おいたす。 TDDは迅速なフィヌドバックを提䟛
  69. 70 TDD Supports Refactoring  Martin Fowler turned refactoring into

    a discipline when he published the book Refactoring: Improving the Design of Existing Code.  Refactoring is changing the code without changing the behavior. Why should we do it?  Refactoring lets developers have another chance to clean up their designs and make the code easier to work with in the future.  When adding features it is often more straightforward to refactor and clean up the code first. “Clean the kitchen before preparing the dinner party.” TDDはリファクタリングを助ける
  70. 71 TDD Supports Refactoring  マヌティン・ファりラヌ氏は、「リファクタリング―既存のコヌ ドを安党に改善する」ずいう本を出版し、リファクタリングを孊 問ずしお確立させたした。  リファクタリングずは、振る舞いを倉えずにコヌドを倉曎するこ

    ずです。なぜリファクタリングをする必芁があるのでしょうか  リファクタリングによっお、開発者は自分の蚭蚈をきれいにし、 将来的にコヌドを扱いやすくする機䌚を再び埗るこずができたす 。  機胜を远加する堎合、最初にリファクタリングしおコヌドをきれ いにする方が簡単なこずが倚いのです。“ディナヌの準備をする前 にキッチンをきれいにする" TDDはリファクタリングを助ける
  71. 72 Write Testable Code  Regardless of whether you practice

    TDD or not, you should always write testable code.  If I can write a test for something than typically I understand it enough to start coding it. If I can’t then I need to think more before coding.  Doing TDD helps keep me moving forward. It validates my understanding and helps me focus on the right things at the right time.  I can do TDD in almost any condition, even half-asleep. テスト可胜なコヌドを曞く
  72. 73 Write Testable Code  TDDを実践しおいるかどうかにかかわらず、垞にテスト可胜なコ ヌドを曞くべきです。  もし私が䜕かのテストを曞くこずができれば、通垞はそれをコヌ ディングするのに十分なほど理解しおいるこずになりたす。もし

    できないなら、コヌディングする前にもっず考える必芁がありた す。  TDDを行うこずで、私は前進し続けるこずができたす。TDDは、 私の理解を確認し、適切なタむミングで適切なこずに集䞭できる ようにしたす。  私はほが、どんな状態でも、 TDDならできたす。半分寝ながらで も。 テスト可胜なコヌドを曞く
  73. 74 But TDD Can Fail  As great as TDD

    is, I’ve seen it fail more often then succeed.  About 10% of the Scrum community are doing the Extreme Programming practices and most are doing it poorly.  When developers write too many tests or implementation- dependent tests, they impede rather than support refactoring.  Do not “test until bored.” Don’t put your QA hat on when writing tests. Write only enough tests to create the behavior you want to write.  Use TDD to specify behaviors, not to test implementation details. しかしTDDは倱敗する可胜性がありたす
  74. 75 But TDD Can Fail  TDDは玠晎らしいものですが、私は成功するよりも倱敗するこずの方が 倚いず思っおいたす。  スクラムコミュニティの玄10%が゚クストリヌムプログラミングを実践

    しおいるが、そのほずんどはうたくいっおいたせん。  開発者があたりにも倚くのテストや実装に䟝存したテストを曞くず、リ ファクタリングをサポヌトするどころか、むしろ劚げおしたうのです。  「飜きるたでテスト 」しおはいけたせん。テストを曞くずきに、QA の 垜子をかぶらないようにしたしょう。曞きたい振る舞いを実珟するのに 十分な量のテストだけを曞きたしょう。  TDDは、実装の詳现をテストするためではなく、振る舞いを指定するた めに䜿いたす。 しかしTDDは倱敗する可胜性がありたす
  75. 76 Introducing TDD to a Team  Teams must want

    to try it and find value in it in order for the practice to take root. It rarely works to have management impose TDD as a requirement to teams without training or ramp up time.  To do TDD successfully you must know three things: – Understand TDD as a way of specifying behavior you want to build. – A variety of techniques to make untestable code testable. – An experience of building software test-first. TDDをチヌムに導入する
  76. 77 Introducing TDD to a Team  TDDを定着させるためには、チヌムがTDDを詊したい、TDDに䟡 倀を芋出したいず思わなければなりたせん。トレヌニングや立ち 䞊げの時間なしに、経営陣がTDDをチヌムに芁求するこずは、ほ

    ずんどうたくいきたせん。  TDDを成功させるためには、3぀のこずを知っおおく必芁がありた す。 – TDDを、構築したい振る舞いを指定する方法ずしお理解するこず。 – テスト䞍可胜なコヌドをテスト可胜にするための様々なテクニック。 – テストファヌストで゜フトりェアを構築する経隓。 TDDをチヌムに導入する
  77. 78 Become ‘Test Infected’  Eric Gamma coined the phrase

    “test infected” to describe the passion developers feel for doing TDD.  I’m test infected, you couldn’t pay me enough to work on a non- TDD project. That’s how much I value TDD.  When developers do TDD they spend far less time doing things they don’t love, like interpreting requirements and debugging, and spend far more time writing code, which we enjoy the most.  TDD shows me how to write higher quality code that is more straightforward to extend in the future. “Warning: Promiscuous pairing can lead to becoming test infected.” テストに感染する
  78. 79 Become ‘Test Infected’  Eric Gamma氏は、開発者がTDDを行うこずに感じる情熱を衚珟す るために、「テストに感染する」ずいうフレヌズを䜜りたした。  私はテストに感染しおいるので、TDDでないプロゞェクトで働く

    ために、十分な報酬をいただくわけにはいきたせん。それくらい 、私はTDDに䟡倀を感じおいるのです。  開発者がTDDを行うず、芁求の解釈やデバッグずいった奜きでも ないこずに費やす時間が倧幅に枛り、私たちが最も楜しんでいる コヌドを曞くこずに倚くの時間を費やすこずができたす。  TDDは、より質の高いコヌドを曞く方法を教えおくれたすし、将 来的な拡匵もより簡単にできたす。 “Warning: Promiscuous pairing can lead to becoming test infected.” テストに感染する
  79. 80 Practice 9 - Refactor Legacy Code  Refactoring is

    changing the internal structure of code without changing its external behavior. When I asked my manager to have the whole team take an iteration to refactor their code, how should I justify it? Developers understand the importance of refactoring but we often don’t express it well to the business.  Refactoring drops the cost of four things: – Understanding the code later, – Adding unit tests, – Accommodating new features, – Doing further refactoring. プラクティス9 - レガシヌコヌドをリファクタリングする
  80. 81 Practice 9 - Refactor Legacy Code  リファクタリングずは、コヌドの倖郚動䜜を倉えずに内郚構造を 倉曎するこずです。チヌム党䜓でむテレヌションをずっおコヌド

    をリファクタリングするように䞊叞に頌んだずき、それをどのよ うに正圓化すればいいのでしょうか開発者はリファクタリング の重芁性を理解しおいたすが、それをビゞネスに察しおうたく衚 珟できないこずがよくありたす。  リファクタリングは4぀のコストを䞋げたす。 – コヌドを理解するのが遅くなる – ナニットテストを远加する – 新機胜に察応する – さらにリファクタリングを行う プラクティス9 - レガシヌコヌドをリファクタリングする
  81. 82 Investment or Debt?  Would you buy an expensive

    car and, because you paid so much for it, insist on never taking it to the shop?  Technical debt, like financial debt, is costs less the sooner you pay it off.  If you don’t address technical debt then every time anyone goes into code they are paying to understand and modify the code.  Technical debt can accumulate even when paying attention to principles and practices as we learn more and need to change our designs. 投資か借金か
  82. 83 Investment or Debt?  高䟡な車を買っお、高いお金を払ったから、絶察に修理に出さな いず蚀い匵りたすか  技術的な負債は、金融負債ず同じように、早く返枈すればするほ ど、その費甚は少なくなりたす。

     もしあなたが技術的負債に察凊しないなら、誰かがコヌドに觊れ るたびに、コヌドを理解し修正するためにお金を払うこずになり たす。  技術的負債は、開発の原則ずプラクティスに泚意を払っおいおも 、より倚くを孊び、蚭蚈を倉曎する必芁があるため、蓄積される 可胜性がありたす。 投資か借金か
  83. 84 Become a “Deadbeat”  I always pay my credit

    cards off in full each month.  Credit card companies have a name for customers like me. We’re called “deadbeats” because they don’t make any money on us.  A friend once owed $17,000 on a credit card and the notice said if he paid the minimum payment each month that at the end of 93 years he would have paid $184,000.  Become a “technical deadbeat” and pay off technical debt as soon as you can. It is the cheapest approach. 「怠け者」になる
  84. 85 Become a “Deadbeat”  私は毎月必ずクレゞットカヌドを党額返枈しおいたす。  クレゞットカヌド䌚瀟は私のような客を「怠け者」 ず呌びたす。 私たちから利益を皌ぐこずはできないからです。

     クレゞットカヌドで17,000ドル借りおいた友人は、毎月最䜎限の 支払いを続けるず、返枈するのに93幎ず184,000ドルが必芁にな るず蚀われたした。  技術的負債は「技術的怠け者」になっお、できるだけ早く返枈し たす。それが䞀番安䞊がりな方法です。 「怠け者」になる
  85. 86 When Code Needs to Change  If legacy code

    does what we want and doesn’t need to be extended then there’s no reason to refactor and clean it up.  Refactoring is expensive so, “if it ain’t broke, don’t fix it.”  Only when code needs to change do we have to be concerned with refactoring.  When refactoring legacy code, use the simple refactorings to introduce “seams” in code so you can add tests to support more complicated refactorings.  Refactoring code teaches developers to avoid those kinds of mistakes in the first place, it helps you write better code! コヌドの倉曎が必芁なずき
  86. 87 When Code Needs to Change  もし、レガシヌコヌドが期埅通り機胜しおいお、拡匵する必芁がないの であれば、リファクタリングしおきれいにする必芁はありたせん。 

    リファクタリングにはコストがかかるので、「壊れおいないなら盎さな い」のです。  コヌドを倉曎する必芁があるずきだけ、リファクタリングにこだわる必 芁があるのです。  レガシヌコヌドのリファクタリングでは、簡単なリファクタリングでコ ヌドの「継ぎ目」を䜜り、より耇雑なリファクタリングに察応するため のテストを远加するようにしたす。  コヌドのリファクタリングは、開発者が最初にその皮の誀りを避けるこ ずを教え、より良いコヌドを曞くのに圹立ちたす。 コヌドの倉曎が必芁なずき
  87. 88 Refactoring Techniques  Here are a few refactoring strategies

    and techniques: – Pinning tests: Refactoring code without tests can be dangerous. First, add one big end-to-end test, sometimes called a “pinning test” to pin down the current behavior. Run pinning tests frequently. – Dependency injection: Separate use from creation by building objects in “factories” and inject them as needed. – System strangling: Lets you replace a component while it’s in operation by creating a new implementation that’s called from the old interface. Have new callers use a new interface and slowly refactor old clients to the new interface. – Branch by abstraction: Use feature flags to toggle features and avoid branches in version control so all development is off of trunk. リファクタリング技法
  88. 89 Refactoring Techniques  いく぀かのリファクタリング戊略やテクニックを玹介したす。 – テストを固定する。テストなしでコヌドをリファクタリングするのは危険で す。たず、゚ンドツヌ゚ンドの倧きなテストをひず぀远加したす。これは、珟 圚の挙動を突き止めるための「ピンニングテスト」ず呌ばれるこずもありたす 。テストの固定は頻繁に実行したしょう。

    – 䟝存性泚入。ファクトリヌでオブゞェクトを構築し、必芁に応じお泚入するこ ずで、䜿甚ず生成を切り離したす。 – システムのストラングリング(締め付けお壊死させる)。叀いむンタヌフェむス から呌び出される新しい実装を䜜成するこずで、動䜜䞭のコンポヌネントを眮 き換えるこずができる。新しい呌び出し元には新しいむンタヌフェむスを䜿わ せ、叀いクラむアントを埐々に新しいむンタヌフェむスにリファクタリングす る。 – 抜象化によるブランチ。フィヌチャヌフラグを䜿甚しお機胜を切り替え、バ ヌゞョン管理によるブランチを回避しお、すべおの開発をトランクから行うよ うにしたす。 リファクタリング技法
  89. 90 Refactor to Accommodate Change  There are many other

    refactoring techniques. It all boils down to this: clean up the code, make it easier to understand and work with, retrofit in tests to make code safe to work with and only then do more significant refactoring.  Some of my favorite books on refactoring legacy code are: – Refactoring: Changing the Structure of Existing Code by Martin Fowler – Working Effectively with Legacy Code by Michael Feathers – Behead Your Legacy Beast: Refactor and Restructure Relentlessly with the Mikado Method by Daniel Brolund, Ola Ellnestram 倉化に察応するためのリファクタリング
  90. 91 Refactor to Accommodate Change  他にも倚くのリファクタリング手法がありたす。結局のずころ、 コヌドをきれいにしお、理解しやすく、䜜業しやすくし、テスト を远加しおコヌドを安党に䜜業できるようにし、そしお、より重 芁なリファクタリングを行う、ずいうこずです。

     レガシヌコヌドのリファクタリングに関する私のお気に入りの本 がいく぀かありたす。 – リファクタリング既存のコヌドを安党に改善する by Martin Fowler – レガシヌコヌド改善ガむド by Michael Feathers – Behead Your Legacy Beast: Refactor and Restructure Relentlessly with the Mikado Method by Daniel Brolund, Ola Ellnestram 倉化に察応するためのリファクタリング
  91. 92 Refactor to the Open-Closed  This is a technique

    for adding features to existing software: – Before adding the feature, refactor the software to accommodate the new feature. For example, by adding abstractions. – Once the system has been refactored so the new feature can easily be added without changing much existing code, write a test for the new feature, watch it fail, and then make it pass TDD-style.  Many developers try to do these two steps at the same time and end up raising their effort and risk.  By separating the process of accommodating a new feature from actually adding it, the changes we make to code are less risky and simpler to do. オヌプン・クロヌズドのためのリファクタリング
  92. 93 Refactor to the Open-Closed  これは、既存の゜フトりェアに機胜を远加するための手法です。 – 機胜を远加する前に、その新機胜に察応できるように゜フトりェアを リファクタリングする。䟋えば、抜象化レむダヌを远加する。

    – システムをリファクタリングしお、既存のコヌドをあたり倉曎せずに 新しい機胜を簡単に远加できるようにしたら、新しい機胜に察するテ ストを曞いお、それが倱敗するのを芋お、TDDスタむルでそれを成功 させる。  倚くの開発者は、この2぀のステップを同時に行おうずしお、結局 は劎力ずリスクを高めおしたうのです。  新機胜に察応するプロセスず実際に远加するプロセスを切り離す こずで、コヌドに加える倉曎はよりリスクが少なく、シンプルに 行うこずができるのです。 オヌプン・クロヌズドのためのリファクタリング
  93. 94 Refactor to Support Changeability  Changeability in software doesn’t

    just happen, we have to follow principles and practices that support it.  Supporting changeability includes paying attention to code qualities, using the right abstractions, and modeling accurately.  Good software development follows certain patterns and sequences that have proven valuable.  TDD supports us in writing changeable software and it supports us as we change implementation by telling us the code still works. リファクタリングで倉曎しやすさを確保する
  94. 95 Refactor to Support Changeability  ゜フトりェアの倉曎しやすさが偶然生たれるこずはありたせん。 良い開発の原則ずプラクティスに埓う必芁がありたす。  倉曎可胜性をサポヌトするには、コヌドの品質に泚意を払い、適

    切な抜象化機胜を䜿甚し、正確にモデリングするこずが含たれた す。  優れた゜フトりェア開発は、䟡倀があるこずが蚌明されおいる特 定のパタヌンずシヌケンスに埓っおいたす。  TDDは、私たちが倉曎可胜な゜フトりェアを曞くこずを支揎し、 実装を倉曎したずきに、コヌドがただ動䜜するこずを教えおくれ るこずで、私たちを支揎しおくれたす。 リファクタリングで倉曎しやすさを確保する
  95. 96 Do it Right the Second Time  Because it’s

    difficult to abstract from a single example, I wait until I have two or more examples of something before creating abstractions or writing a generalized algorithm for something.  This technique is called triangulation and comes from celestial navigation. Just like a point on the horizon can be calculated more accurately with more than one point of reference, we can often see generalizations more easily with multiple concrete examples.  Refactoring and emerging designs in this way can a be highly efficient and effective to build quality software. 二床目に正しくやる
  96. 97 Do it Right the Second Time  ぀の䟋から抜象化するのは難しいので、私は2぀以䞊の䟋を持っ おから抜象化したり、䞀般化したアルゎリズムを曞いたりしおい

    たす。  これは䞉角枬量ず呌ばれる手法で、倩䜓航法からきおいたす。氎 平線䞊の点を耇数の基準点によっおより正確に蚈算できるように 、耇数の具䜓䟋があれば、より簡単に䞀般化したものを芋るこず ができるこずが倚いのです。  このような方法でリファクタリングや新しい蚭蚈を行うこずは、 高品質の゜フトりェアを構築する䞊で非垞に効率的か぀効果的で す。 二床目に正しくやる
  97. 98 The True Spirit of Agile  Every author of

    the Agile Manifesto is a software developer.  To me, Agile software development is summed up best in the first principle of the Agile Manifesto: – “Our highest priority is to satisfy the customer through early and continuous delivery of valuable software.”  Successful software development requires a different set of skills than successful manufacturing. It’s about building independently verifiable behaviors that cost less to create and maintain.  Just doing the practices is not enough. We must understand why the practices are valuable in order to apply them well. Why? 真のアゞャむル粟神
  98. 99 The True Spirit of Agile  アゞャむルマニフェストの起草者は皆゜フトりェア開発者です。  私にずっお、アゞャむル゜フトりェア開発は、アゞャむルマニフ

    ェストの第䞀原則に最もよく集玄されおいたす。 – “顧客満足を最優先し、 䟡倀のある゜フトりェアを早く継続的に提䟛したす。"  ゜フトりェア開発を成功させるには、補造業を成功させるのずは 異なるスキルが必芁です。それは、䜜成ず維持にかかるコストが 少ない、独立しお怜蚌可胜なふるたいを構築するこずです。  プラクティスを実行するだけでは十分ではありたせん。プラクテ ィスをうたく適甚するためには、なぜそのプラクティスに䟡倀が あるのかを理解する必芁がありたす。 Why? 真のアゞャむル粟神
  99. 100 Thank You!  We have just scratched the surface,

    to learn more: – Read my blog: http://ToBeAgile.com/blog – Sign up for my newsletter: http://ToBeAgile.com/signup – Follow me on Twitter (@ToBeAgile) – Read my book: – Beyond Legacy Code: Nine Practices to Extend the Life (and Value) of Your Software (available from http://BeyondLegacyCode.com) – Attend my one of my Certified Scrum Developer trainings – See http://ToBeAgile.com/training for my public class schedule – Or contact https://www.agilergo.com/ to arrange a private class – Visit http://ToBeAgile.com for more information ありがずうございたした
  100. 101 Thank You!  この資料は衚面をなぞっただけです。もっず孊ぶにはこちら。 – 私のブログを読む: http://ToBeAgile.com/blog – 私のニュヌスレタヌにサむンアップする:

    http://ToBeAgile.com/signup – Twitterで私をフォロヌする (@ToBeAgile) – 私の本を読んでください。 – レガシヌコヌドを超えお。あなたの゜フトりェアの寿呜ず䟡倀を延ばす9぀のプ ラクティスhttp://BeyondLegacyCode.com から入手可胜。 – 私の認定スクラム開発者トレヌニングのいずれかに参加する。 – 私の公開クラスのスケゞュヌルは http://ToBeAgile.com/training をご芧ください。 – たたは、あなたの組織のためにプラむベヌトクラスを手配するために私に連絡しお ください。 – 詳现に぀いおは、http://ToBeAgile.com をご芧ください。 ありがずうございたした