0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

重い処理をサボるデザインパターンの図的理解

Posted at

巷で(多分) proxy パターンと呼ばれているデザインパターンを図的に理解しよう1

重い処理

画像に示すような激重処理があったとする。

image.png

入出力の分割

重い処理の入力部分・処理部分・出力部分を別々に切り分けると必要なときに必要な分だけ処理できるようになる

image.png

全体的な複雑性は増しているが、各部分の処理に着目するとシンプルになっている

出力部分

image.png
重い処理の部分は必要になるまで待機している (lazy load)

image.png
注文が入ると重い処理が動き、出力する

入力部分

image.png

計算に必要なリソースを取ってくる領域を確保しておき、計算するときに取ってくる

image.png
リソースを配置する処理は別で行われても良い。
図ではストリームをバッファに溜め込んでおき、ある程度時間が経ったら捨てる処理をイメージしている。
このような処理は、例えば、信号処理をリアルタイムに行う場合などに現れる。

  1. 名前に関しては自信がないので、違ってたら教えて下さい

0
0
0

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?