Movatterモバイル変換


[0]ホーム

URL:


LoginSignup
1

Go to list of users who liked

1

Share on X(Twitter)

Share on Facebook

Add to Hatena Bookmark

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Ruboty | Extract gem Pattern を用いて Ruboty Plugin 内で利用する一塊の機能を持つロジックを外部 gem 化する #ruboty

Last updated atPosted at 2014-12-08

Ruboty | Extract gem Pattern を用いて Ruboty Plugin 内で利用する一塊の機能を持つロジックを外部 gem 化する

概要

Extract gem Pattern を用いて Ruboty Plugin 内で利用する一塊の機能を持つロジックを外部 gem 化します

Extract gem Pattern とは?

一塊の機能を持つプログラムを外部 gem 化するパターン。
私が勝手に命名しました。
すでにどこかで命名されているかもしれませんし、ただ単に単一機能を切り出して gem にするだけの話です。

Extract ○○ という命名はリファクタリングカタログ

  • Extract Class
  • Extract Method

などに合わせた命名です。

Ruboty Plugin 開発時の課題

  • Ruboty の仕組みの中でテストをするので、内部に 一塊の機能を持つロジックを含む場合、
    本来のテスト対象の In - Out をテストするよりもコストが高くなる。

Extract gem の効果

  • 単一の機能に専念することでテスタビリティが上がる
  • 他のプログラムからも利用可能になる

Extract gem 適用前の構成

extract_gem_before.png

Extract gem 適用後の構成

extract_gem_after.png

補足

  • 外部 gem 化するほどでもない機能なら、Extract Class で別ファイルにしてテスタビリティを上げるのもよい。
  • Hubot も・・・

参照

Martin Fowler | Catalog of Refactorings

1

Go to list of users who liked

1
0

Go to list of comments

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1

Go to list of users who liked

1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?


[8]ページ先頭

©2009-2025 Movatter.jp