凪瀬 Blog
Programming SHOT BAR

目次

Blog 利用状況
  • 投稿数 - 260
  • 記事 - 0
  • コメント - 2874
  • トラックバック - 192
ニュース
広告
  • Java開発者募集中
  • 経歴不問
  • 腕に自信のある方
  • 富山市内
  • (株)凪瀬アーキテクツ
アクセサリ
  • あわせて読みたい
凪瀬悠輝(なぎせ ゆうき)
  • Java技術者
  • お茶好き。カクテル好き。
  • 所属は(株)凪瀬アーキテクツ
  • Twitter:@nagise

書庫

日記カテゴリ

 

GoFデザインパターンはなかなか奥深く、入門書を読んでパターンごとのクラスの絡み合いを理解しただけでは 真価を理解できないことが多々あります。
独習デザインパターン のクラス図からAbstract Factoryパターン と Builderパターンの違いがうまく説明できなかったので GoF本を紐解いて その目的を調べてみました。

Abstract Factoryパターンの適用可能性

Abstract Factoryでは、「ある抽象的な型の実装を返す」というインターフェースを定義し、 そのインターフェースの実装を多種揃えるといった形になります。

GoF本では例としてlook&feelを取り上げています。 JavaのswingのライブラリではUIのデザインをごっそり切り替えることができますが、 その具象クラスの生成を具象型を知らずに行いたいというようなケースを想定すればよいのでしょう。

GoF本では適用可能性に以下をあげています。

Abstract Factory パターンは、以下のような場合に有効である。

  • システムを部品の生成、組み合わせ、表現の方法から独立にすべき場合。
  • 部品の集合が複数存在して、その中の1つを選んでシステムを構築する場合。
  • 一群の関連する部品を常に使用しなければならないように設計する場合。
  • 部品のクラスライブラリを提供する際に、インターフェースだけを公開して、実装は非公開にしたい場合。

look&feelは2番目の条項ですね。look&feelの例からすると、 多数のクラス群をごっそり切り替える場合にAbstract Factory パターンを適用するのが分かります。

Builderパターンの適用可能性

Builderパターンでは「多くの構成要素からなるオブジェクトを組み立てるための部品を返す」インターフェースを定義します。 そしてこの実装を多種揃えることになります。
この部分のクラスだけを見ているとAbstract Factoryとなんら変わらないように見えたのです。

決定的な違いは、Abstract Factoryが呼び出し元となるクラスを特定しておらず、 メソッドの呼び出しに応じて完成品を返すということ。
BuilderはDirectorと呼ばれる特定のクラスからの呼び出しを期待しており、 一個の完成品を返すというよりも、それを組み立てるためのパーツを返すという点。 完成品となるオブジェクトはDirectorクラスが不特定多数のクラスの呼び出しに応じて返すことになります。

この目的というか適用部分を把握するとなるほど目的が違うことがはっきりわかります。 GoF本では適用可能性として以下を挙げています。

Builder パターンは、次のような場合に適用することができる。

  • 多くの構成要素からなるオブジェクトを生成するアルゴリズムを、構成要素自体やそれらが どのように組み合わされるのかということから独立にしておきたい場合。
  • オブジェクトの作成プロセスが、オブジェクトに対する多様な表現を認めるようにしておかなければならない場合。

GoF本への回帰

GoFデザインパターンを解説した本は数ありますが、GoFの23個のパターンすべてを網羅しているにもかかわらず そのページ数がGoF本のそれと大して変わらないものが多くあります。(GoF本が412ページ)

それらの本では、オブジェクト指向の扱い方についての説明に終始しているものが多く、 コードレベルでどうなっているか、そこに使われるオブジェクト指向のテクニックは何か、 そのあたりをターゲットにしているように思います。

一方の本家であるGoFは、あくまで「デザインパターン」の本であり、 そんな細かいテクニックは当然知っている前提で、どのように設計するのかという視点で書かれています。

デザインパターン入門書の類の説明では設計にどう生かすのか分らないと思ったらGoFを紐解きましょう。 入門書ではカットされたエッセンスがそこには詰まっています。

投稿日時 : 2007年12月19日 9:57
コメント
  • # emePhHKscE
    http://crorkz.com/
    Posted @ 2014/08/28 2:38
    YwZDuk Hello there, I found your website via Google while looking for a related topic, your website came up, it looks great. I've bookmarked it in my google bookmarks.
  • # qkrCoKblfdiiJWdcs
    https://fifa14hackcoins.wordpress.com/
    Posted @ 2014/09/01 20:13
    Wonderful website. A lot of useful info here. I'm sending it to a few friends ans also sharing in delicious. And naturally, thanks for your effort!
  • # VTjttfYhParzJwFj
    https://www.facebook.com/SunsetValleyHolidayHouses
    Posted @ 2014/09/10 15:48
    Hello! I just wish to give an enormous thumbs up for the good data you've here on this post. I will probably be coming back to your weblog for more soon.
  • # bLdRWJQQcuAuViyX
    http://ecommerce-investments.com/
    Posted @ 2014/09/16 7:35
    Hey! I simply would like to give a huge thumbs up for the great information you will have here on this post. I will probably be coming back to your weblog for extra soon.
  • # TIfOWrtQWcjbMONGv
    http://articlewon.info/story.php?id=98657
    Posted @ 2014/09/18 16:15
    AJUiEz Im thankful for the blog post.Thanks Again. Much obliged.
  • # pXOtAQpRPMELnitONoV
    varlog
    Posted @ 2015/01/12 1:03
    lnqF9R http://www.FyLitCl7Pf7kjQdDUOLQOuaxTXbj5iNG.com
  • # ZGYyvlNiiwOKJKx
    Rolando
    Posted @ 2015/01/28 3:56
    Insert your card http://www.theislamicmonthly.com/advertising/ buy zolpidem next day Tepco is trying to prevent groundwater from reaching the plant by building a "bypass" but recent spikes of radioactive elements in sea water has prompted the utility to reverse months of denials and finally admit that tainted water is reaching the sea.
  • # iufxVsrdoNCTRjv
    Danny
    Posted @ 2015/01/28 3:57
    I can't hear you very well http://www.politicaltheology.com/blog/standinginwitness/ zopiclone 7.5 mg buy online Kwiatkowski, who grew up in Michigan, later began work as a traveler sent by staffing agencies to hospitals around the country, usually for temporary jobs. In announcing federal drug charges last year, U.S. Attorney John Kacavas called him a "serial infector."
  • # argsOwdWlfJJym
    Angelina
    Posted @ 2015/02/06 1:36
    Gloomy tales http://www.retendo.com.pl/sklep/ buy domperidone tablets Brewing companies complained last month before Congress that banks were pushing up the price of aluminum, which is used in beer cans, by delaying delivery times and creating long queues for the metals warehouses they own.
  • # ZANnZDEVZlWBkwbp
    Marcus
    Posted @ 2015/02/06 12:29
    What do you study? http://www.grasmerehotel.com/conferences/ 300 dollars loan with bad cerdit The deadline for funding the U.S. government is September 30, when a so-called "continuing resolution" enacted last March expires. By mid-October or early November, the U.S. Treasury likely will run out of borrowing authority.
  • # ArQvDWEHagKE
    Jesus
    Posted @ 2015/02/06 12:29
    Would you like a receipt? http://www.altenergetika.com/o-nama cash sweepstake Current services to Scotland's rural areas highlight the importance of keeping this service in the public's hands. Due to the number of remote populations with limited transport links, the cost of providing Royal Mail's services in Scotland are significantly more expensive than the UK average.
  • # jCBtcKEzKfNQMoO
    Dewey
    Posted @ 2015/02/07 6:09
    Insufficient funds http://www.wonderbra.ca/about-us/ tenormin tablet Four weeks later, Leah emailed to say the Odeh family had received my letter and wanted to learn more about my motivations. Leah arranged to visit them on my behalf. When Leah emailed again it was to tell me that the meeting had gone well. They had said how shocked they’d been after learning what had happened, that they would have stopped Mohammad had they known. That he was no hero. Mohammad, they’d said, was the gentlest of the family, the most vulnerable. He’d been mistreated by Israeli soldiers and must have reached a point where he just broke under the pressure. It’s the only explanation. And they’d said they welcomed me with open arms and that they would ask Mohammad about meeting me. A few weeks later Leah’s translator Mariam wrote to tell me Mohammad had agreed.
  • # UBLQTUicerbhX
    Goodboy
    Posted @ 2015/02/07 6:09
    I've only just arrived http://www.wonderbra.ca/products-page/ tenormin 100 mg para sirve The roads, especially outside of Rio, can be extremely bumpy and the distances between the cities are vast. The shortest distance between the hosts cities is the six and a half hours it will take you to get from Rio to Belo Horizonte. The longest distance is from Curitiba to Manaus - a four hour and 15 minute flight.
  • # ERaNQhqTvKgQThCC
    Andre
    Posted @ 2015/02/09 5:59
    Children with disabilities http://www.sporttaplalkozas.com/sporttaplalkozas/sporttaplalkozas-program sallie mae smart loans SFR and Orange are aiming to cover 40 percent of thepopulation by the end of the year. Both have said they aim forat least 1 million 4G customers by the end of the year. Bouygueshas not given a customer target.
  • # GHPoBTzEZUDcv
    Maximo
    Posted @ 2015/02/09 5:59
    Accountant supermarket manager http://atecuccod.com/index.php/aszf need loan fast The picture, which accompanies a story titled "Jahar's World," shows the accused murderer with his long, curly hair tousled and the hint of a goatee, reminiscent of the magazine's iconic shots of rock 'n' roll royalty like The Doors' Jim Morrison. The cover could send a dangerous message to Tsarnaev's warped supporters, according to one critic.
  • # RbDgqpbPWUQ
    Wallace
    Posted @ 2015/02/09 13:47
    It's OK http://www.larkspurdata.com/dmp1.html order singulair online Smoltz's 18,000-square-foot mansion has 10 full bathrooms and 4 half baths. The elegant estate, which was built in 2002, includes an "au pair suite" and studio apartment. It also boasts an eight-car garage and three finished levels.
  • # zkgzefvyNDLSwELRlBf
    Jozef
    Posted @ 2015/02/10 13:56
    I went to http://www.wildfirerhc.org/about/ bad credit loan loan personal unsecured India�s benchmark stock index is down more than 5 percent in the past week and Thailand has fallen more than 6 percent. Indonesia�s Jakarta Composite Index lost 10 percent in that period and is down about 20 percent since its close on May 20.
  • # olmFYlJVAevGv
    Gabrielle
    Posted @ 2015/02/11 22:20
    Can I call you back? http://thisisaway.org/get-involved/ loan any purpose Open Access Orders operate very differently; they are more stable, even in times of crisis,  because of the density, legitimacy and resilience of their institutions. Their "logic," as North calls it, has led to massive wealth creation, large middle classes, stable democratic political systems that protect individual rights and limit arbitrary government action. Limited Access countries can grow into Open Access Orders by developing inclusive public and private institutions over a long and difficult process, by opening up their economies to competition, building stronger institutions and providing public services and the rule of law broadly across the society.
  • # QsPOZnVVnCDoGKp
    Tyree
    Posted @ 2015/02/11 22:20
    How do you spell that? http://thisisaway.org/get-involved/ short term loans kansas city Nearly half of the money raised in the new campaign will support teaching and research, while a quarter will go for financial aid and related programs. The rest will go toward capital improvements and a flexible fund, according to Harvard, recently ranked America's No. 2 university behind Princeton by U.S. News & World Report.
  • # AzGtoMmSey
    Neville
    Posted @ 2015/02/24 17:30
    I'd like some euros http://www.streamsweden.com/nyheter/ propranolol 10mg for anxiety Mentorship should not be a one-way flow of information and value. Don't simply dictate.  Let go of your ego. Be humble and be willing to grow together. While one party may have more knowledge and experience, make the relationship more meaningful by fostering an atmosphere of collaboration.
  • # evVwBIAknfHDKMIJCaf
    Augustus
    Posted @ 2015/02/26 23:55
    Jonny was here http://www.alexscheele.co.uk/services/ Coreg Er Mattingly talked later about having to “shoot your bullet when you get a chance.” Had it worked, he would have gotten away with it and come off as a gutsy genius. When it didn't work, it looked bad. Real bad.
  • # jLyvlAogehZoFPPtRG
    Laverne
    Posted @ 2015/02/28 10:34
    I can't get a signal https://rarcc.org/contact-us purchase bimatoprost pills A source close to the company told Reuters that Alibaba, noweffectively controlled by a group of 28 "partners" including Ma,senior executives and other insiders, is intent on keeping asimilar structure when it goes public. Listing in the U.S. makesthat possible, a key consideration in choosing New York overHong Kong, the source said.
  • # XdgRIbjgwpO
    Robby
    Posted @ 2015/02/28 10:34
    I have my own business http://version22.com/about/ xalatan cheap Their view is backed up by the volume of grains collected by the wheat marketing monopoly so far. It has received only 950,000 tons, according to officials in the state run General Establishment for Cereal Processing and Trade (HABOOB).
  • # ylngEBLpyIxYggOmE
    Francisco
    Posted @ 2015/02/28 10:35
    Which year are you in? https://rarcc.org/contact-us bimatoprost 0.03 solution Penney and Stewart argued that the Macy's contract allowsStewart to sell branded goods in Martha Stewart retail storesand that the shops within Penney department stores would, infact, be Martha Stewart retail stores.
  • # KIYaMzUnyQQcgfDNp
    Raymundo
    Posted @ 2015/04/07 0:26
    History http://www.streamsweden.com/tjanster/ purchase propranolol online Overheated water has been blamed for large die-offs of hatchery trout and salmon stocks in at least two parts of the state as hot, dry weather has set in, according to the Alaska Department of Fish and Game.
  • # MyrGTBbWAsIezktOZV
    Angelina
    Posted @ 2015/04/07 0:26
    Recorded Delivery http://www.streamsweden.com/tjanster/ propranolol prescription anxiety Penney earlier this year lined up a five-year $2.25 billion financing package to shore up its liquidity after sales fell 25 percent last fiscal year under former Chief Executive Ron Johnson's failed attempt to remake Penney into a more fashionable department store.
  • # HLakPVfdbc
    Charlotte
    Posted @ 2015/04/08 1:40
    I'm unemployed http://www.europanova.eu/partenaires/ latisse sale ebay �One ate rice and fruit and walked. The staff didn�t care what you thought, only what you ate and how often you exercised,� said Anspaugh, whose book about her experiences with the program is called �Fat Like Us.�
  • # dZdwRwgBRlDfLozh
    chaba
    Posted @ 2015/05/03 0:54
    4FqYeB http://www.FyLitCl7Pf7kjQdDUOLQOuaxTXbj5iNG.com
  • # blood pressure levels
    jeazopkayappy
    Posted @ 2015/06/07 22:49
    <u>http://hejmon.com/</u> - pressure levels
  • # Utah Lawn Care
    Utah Lawn Care @@mower.net
    Posted @ 2016/06/01 0:56
    One Man and a Mower lawn maintenance provides the most outstanding service for your lawn in Salt Lake, Utah. One Man and a Mower lawn service is costs less than most other agencies and gives better service.
  • # www.erectionskill.com
    erectionskill.com
    Posted @ 2016/06/09 10:43
    This is a high-grade nightmarish article thanks on the side of sharing this enlightening information.
  • # how much is the discount rolex mens yellow gold watch
    deglkccuzcefsbsykiifbl@hotmal.com
    Posted @ 2017/07/07 7:03
    I am not shocked or surprised by this at all.The fact that is an American who came up with this BS surprises me even less. We all know of insurance companies only too happy to relieve you of your money but who do not wish to part with it when you wish to make a legitimate claim. It is vile that the government allows this but then what do you expect from corrupt government and this proves without a shadow of a doubt, the lies told and the campaign against the sick and disabled.
    how much is the discount rolex mens yellow gold watch http://www.crownuhr.nl/rolex-day-date-president-c6/
  • # ブランド コピー
    otwmqudm@ybb.ne.jp
    Posted @ 2017/10/11 0:52
    とにかく今まで色々購入してきましたが、一番!!と言えるくらい最高に丁寧な梱包で、感動すら覚えました!!
    ありがとうございました!!
    また機会があればぜひお付き合いしたいと思いました!!
  • # ブランド激安市場
    ckgmqdntk@ezwen.ne.jp
    Posted @ 2017/10/27 16:39
    無事に商品が届きました。梱包はとても丁寧でお店の誠実さが伝わりました。
    また、利用したいお店。そういう気持ちにさせてくれるショップでした。ありがとうございました。
    ブランド激安市場 http://www.newkakaku.net
  • # ROLEX 腕時計
    zqhaurvsfu@excite.co.jp
    Posted @ 2017/10/28 14:21
    とても良心的でいいショップです。商品の過剰ランク評価もなく良かったです。
    【送料無料】★ルイヴィトン★ダミエ・グラフィット★ポルトフォイユ・アコルディオン★チェーン付長財布★N60023★
    思っていた以上に商品の状態が良かったです。
    ROLEX 腕時計 http://www.yamamo78.com/web/watch-ro001.htm
  • # A品ルイヴィトン
    fykfyaxjwq@ocn.ne.jp
    Posted @ 2017/11/08 5:05
    とても商品のコメントが信じられて、リピートしちゃってます。
    質問等、MAILでのやりとりしてくれるし、親切丁寧わかりやすい!
    これからもヨロピクです☆
    【送料無料】ルイヴィトン コインケースをセール価格で販売中♪ルイヴィトン コインケース モノグラム ヴェルニ ポルト モネ フロコン M58218 アルジャン 新品 雪 スノーフレーク チェーン チャーム LOUIS VUITTON
    感動!
    超綺麗でした!
    多少のキズは覚悟していたのですが、全然目立たなくて・・・
    早速お気に入りです。
    A品ルイヴィトン http://www.nawane111.com/hermes-bag.htm
  • # ルイヴィトンコピーアウトレット
    ktjtuyro@softbank.ne.jp
    Posted @ 2017/11/28 18:12
    そんな重力波、人類が検出できるような大きさの時空の歪みを発生させるためには、かなりかなり重いものを動かしてやらないといけません。
    今ここでこの本を振り回してももちろん重力波は発生するのですが、とてもとても検出できるような歪みではないのです。
    それなら何を動かすのか。
    そこで、困ったときの宇宙頼みです。
タイトル  
名前  
Url
コメント