Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

Refactoring to Patterns

書籍 Refactoring to Patterns | Utilities

パンくず 書籍 Refactoring to Patterns Utilities 概要 Utilities、ユーティリティーに関するリファクタリング ユーティリティーに関するリファクタリング Refactoring リファクタリング Chain Constructors コンストラクタの連鎖 Unity Interface インター…

書籍 Refactoring to Patterns | Accumulation| Move Accumulation to Visitor

パンくず 書籍 Refactoring to Patterns Accumulation Move Accumulation to Visitor 概要 Move Accumuration to Visitorについて 使用する場面 1つのメソッドが異種のオブジェクトから情報を累積する場合 対応方法 Visitorパターンを使用する 利点と欠点 利…

書籍 Refactoring to Patterns | Accumulation| Move Accumulation to Collecting Parameter

パンくず 書籍 Refactoring to Patterns Accumulation Move Accumulation to Collecting Parameter 概要 Move Accumulation to Collecting Parameterについて 使用する場面 一つのローカル変数に対する変更をまとめて行なっている一つのメソッドがあるなら、…

書籍 Refactoring to Patterns | Accumulation

パンくず 書籍 Refactoring to Patterns Accumulation 概要 Accumulation、蓄積に関するリファクタリング 蓄積に関するリファクタリング Refactoring リファクタリング Move Accumulation to Collectiing Parameter Collecting Parameterによる累積処理の書…

書籍 Refactoring to Patterns | Utilities | Extract Parameter

パンくず 書籍 Refactoring to Patterns Utilities Extract Parameter 概要 Extract Parameterについて 使用する場面 委譲の利用時に他のオブジェクトのインスタンス生成のための パラメータが必要な場合。 対応方法 Extract Parameterを適用する。 サンプル…

書籍 Refactoring to Patterns | Utilities | Unity Interface

パンくず 書籍 Refactoring to Patterns Utilities Unity Interface 概要 Unity Interfaceについて 使用する場面 複数の子クラスに、共通するシグニチャのメソッドがあるがインターフェース もしくは抽象基底クラスにインターフェースが用意されていない。 …

書籍 Refactoring to Patterns | Utilities | Chain Constructors

パンくず 書籍 Refactoring to Patterns Utilities Chain Constructors 概要 Chain Constructorsについて 使用する場面 複数のコンストラクタの内容が重複している。 対応方法 Chain Constructorsを適用する。 全体に共通するコンストラクタを用意し、各コン…

書籍 Refactoring to Patterns | Protection | Introduce Null Object

パンくず 書籍 Patterns to Patterns Protection Introduce Null Object 概要 Introduce Null Objectについて 使用する場面 大量のNullチェックがある場合 対応方法 Null Objectを導入します 利点と欠点 利点 ・Nullロジックの重複を防ぎ、Nullエラーを防ぐ …

書籍 Refactoring to Patterns | Protection | Limit Instantiation with Singleton

パンくず 書籍 Patterns to Patterns Protection Limit Instantiation with Singleton 概要 Limit Instantiation with Singletonについて 使用する場面 パフォーマンスやメモリーの、都合でひとつのインスタンスにしたい場合 対応方法 Singletonパターンを適…

書籍 Refactoring to Patterns | Protection

パンくず 書籍 Refactoring to Patterns Protection 概要 Protection、保護に関するリファクタリング 保護に関するリファクタリング Refactoring リファクタリング Replace Type Code with Class クラスによる型コードの置換 Limit Instantiation with Singl…

書籍 Refactoring to Patterns | Protection| Replace Type Code with Class

パンくず 書籍 Patterns to Patterns Protection Replace Type Code with Class 概要 Replace Type Code with Classについて 使用する場面 タイプの指定ミスによるバグが想定される場合。 対応方法 Stateパターンを適用します 利点と欠点 利点 ・不正なパラ…

書籍 Refactoring to Patterns | Generalization | Replace Inplicit Language with Interpreter

パンくず 書籍 Patterns to Patterns Generalization Replace Inplicit Language with Interpreter 概要 Replace Inplicit Language with Interpreterについて 使用する場面 シンプルだが組み合わせが多いような問題の解決が必要。 対応方法 Interpreterパタ…

書籍 Refactoring to Patterns | Generalization | Extract Adapter

パンくず 書籍 Patterns to Patterns Generalization Extract Adapter 概要 Extract Adapterについて 使用する場面 複数バージョンをサポートしなければならない場合。 対応方法 Adapterを適用する。 利点と欠点 利点 ・API,ライブラリ、コンポーネントの異…

書籍 Refactoring to Patterns | Generalization | Unify Interface with Adapter

パンくず 書籍 Patterns to Patterns Generalization Unify Interface with Adapter 概要 Unify Interface with Adapterについて 使用する場面 ・2つのクラスが似ているがインターフェースが異なる場合。 ・サードパーティの製品等、制約の関係上インターフ…

書籍 Refactoring to Patterns | Generalization | Replace Hard-Cord Notification with Observer

パンくず 書籍 Patterns to Patterns Generalization Replace Hard-Cord Notification with Observer 概要 Replace Hard-Cord Notification with Observerのリファクタリングについて 使用する場面 1つのReceiverしか受け取らないNotifierがあり、ハードコー…

書籍 Refactoring to Patterns | Generalization | Replace One/Many Distinction with Composite

パンくず 書籍 Patterns to Patterns Generalization Replace One/Many Distinction with Composite 概要 Replace One/Many Distinction with Compositeのリファクタリングについて 使用する場面 あるクラスがひとつのオブジェクトと多数のオブジェクトを扱…

書籍 Refactoring to Patterns | Generalization | Extract Composite

パンくず 書籍 Patterns to Patterns Generalization Extract Composite 概要 Extract Compositeのリファクタリングについて 使用する場面 2つ以上の似たクラスを保持している場合 対応方法 Compositeパターンを適用する。 利点と欠点 利点 ・子の格納と処理…

書籍 Refactoring to Patterns | Generalization| Form Template Method

パンくず 書籍 Patterns to Patterns Generalization Form Template Method 概要 Form Template Methodのリファクタリングについて 使用する場面 サブクラスに変数となる箇所と非変数となる箇所が混ざっている場合、非変数となる箇所はサブクラスで重複して…

書籍 Refactoring to Patterns | Generalization

パンくず 書籍 Refactoring to Patterns Generalization 概要 Generalization、汎化に関するリファクタリング 汎化に関するリファクタリング Refactoring リファクタリング Form Template Method Template Methodの形成 Extract Composite Compositeの抽出 R…

書籍 Refactoring to Patterns | Simplification | Move Embellishment to Decorator

パンくず 書籍 Patterns to Patterns Simplification Move Embellishment to Decorator 概要 Move Embellishment to Decoratorのリファクタリングについて 使用する場面 核となる機能に飾るような機能を追加する場合、 既存のクラスに特定のケースのみ動作す…

書籍 Refactoring to Patterns | Simplification | Replace Conditional Logic with Strategy

パンくず 書籍 Patterns to Patterns Simplification Replace Conditional Logic with Strategy 概要 Replace Conditional Logic with Strategyのリファクタリングについて 使用する場面 Martin Fowler曰く「プログラムの複雑性のもっとも一般的なものの一つ…

書籍 Refactoring to Patterns | Simplification | Compose Method

パンくず 書籍 Patterns to Patterns Simplification Compose Method 概要 Compose Methodのリファクタリングについて 使用する場面 雑然とした長い処理のメソッドなどがある場合 対応方法 同レベルの粒度でExtract Methodを適用する。 役割を表す分かりやす…

書籍 Refactoring to Patterns | Simplification

パンくず 書籍 Refactoring to Patterns Simplification 概要 Simplification、単純化に関するリファクタリング 単純化に関するリファクタリング Refactoring リファクタリング 補足 Compose Method メソッドの構造化 ーー Replace Conditional Logic with S…

書籍 Refactoring to Patterns | Creation | Inline Singleton

パンくず 書籍 Patterns to Patterns Creation Inline Singleton 概要 Inline Singletonのリファクタリングについて 使用する場面 Singletonitisは、Singletonパターンを適用することと定義します。 Singletonの目的はインスタンスが一つしかないことを保証…

書籍 Refactoring to Patterns | Creation | Encapsulate Composit Builder

パンくず 書籍 Patterns to Patterns Creation Encapsulate Composit Builder 概要 Encapsulate Composit Builderのリファクタリングについて 使用する場面 複雑化したCompositeを含む生成ロジックをクライアントから切り離したい場合 対応方法 Builderを作…

書籍 Refactoring to Patterns | Creation | Introduce Polymorphic Creation With Factory Method

パンくず 書籍 Patterns to Patterns Creation Introduce Polymorphic Creation With Factory Method 概要 Introduce Polymorphic Creation With Factory Methodのリファクタリングについて 使用する場面 複数のクラスを同一の型で扱うFactory Methodにした…

書籍 Refactoring to Patterns | Creation | Encapsulate Classes with Factory

パンくず 書籍 Patterns to Patterns Creation Encapsulate Classes with Factory 概要 Encapsulate Classes with Factoryのリファクタリングについて 使用する場面 一つのインターフェースを実装したクラスが複数あった場合に、 必要最低限のクラスのみ外部…

書籍 Refactoring to Patterns | Creation | Move Creation Knowledge to Factory

パンくず 書籍 Patterns to Patterns Creation Move Creation Knowledge to Factory 概要 Move Creation Knowledge to Factoryのリファクタリングについて 使用する場面 オブジェクトの生成にいくつか設定が必要であり、 生成のための処理を各クライアント側…

書籍 Refactoring to Patterns | Creation | Replace Constructors with Creation Method

パンくず 書籍 Patterns to Patterns Creation Replace Constructors with Creation Method 概要 Replace Constructors with Creation Methodのリファクタリングについて 使用する場面 オーバーロードした多数のコンストラクタが存在し、 クラスを利用する側…

書籍 Refactoring to Patterns | Creation

パンくず 書籍 Refactoring to Patterns Creation 概要 Creation、生成に関するリファクタリング 生成に関するリファクタリング Refactoring リファクタリング Replace Constructors with Creation Method Creation Methodによるコンストラクタの置換 Move C…