=
ホーム
On Your Mark
ホーム
/
設計(Java)
/
【設計】 デザインパターン:FactoryMethod
2013年7月11日木曜日
デザインパターン
設計(Java)
t
f
B!
P
L
# FactoryMethod ## 概要 FactoryMethodは直訳で「工場メソッド」。 オブジェクトの生成を担うパターンです。 ## ポイント メソッドを生成する際、newを使用して生成するより、 メソッドを解して、生成をすることで、 より柔軟に生成処理を行うことができます。 ## 例 <pre> public abstract class Print{ abstract void draw(Pen pen); public Pen createPen() { return new BallPen(); } public void create() { Pen pen = createPen(); draw(pen); } } public class ColorPaint extends Print { protected void draw(Pen pen){ } protected Pen createPen(){ // createPenをオーバーライド return new ColorPen(); } } </pre>
Translate
このブログを検索
ブログアーカイブ
►
2020
(38)
6月 2020
(6)
5月 2020
(10)
4月 2020
(10)
3月 2020
(4)
2月 2020
(5)
1月 2020
(3)
►
2019
(4)
1月 2019
(4)
►
2018
(23)
12月 2018
(3)
4月 2018
(11)
3月 2018
(9)
►
2014
(20)
7月 2014
(3)
1月 2014
(17)
▼
2013
(166)
12月 2013
(15)
11月 2013
(22)
10月 2013
(31)
9月 2013
(26)
8月 2013
(32)
7月 2013
(40)
今週の人気の記事
【まとめ】GWはおうちでぬりえ 鉄道会社公式の電車ぬりえをまとめた
【MySQL】文字列をバイト数で切り取る
【まとめ】おうちでペーパークラフト 鉄道会社公式のペーパークラフトをまとめた
【Trac】 Trac Lightning と Git を連携させる
【PHP】PHPでSFTP接続
フォロワー
On Your Mark
QooQ
0 件のコメント:
コメントを投稿