Software design pattern

From Wikipedia
Jump to navigation Jump to search

Ebunjiniyela be-software, ubunjiniyela, iphethini yokwakheka kwesoftware iyisisombululo esijwayelekile, esisebenzisekayo senkinga evame ukwenzeka ngaphakathi komongo inikezwe ekwakhiweni kwesoftware. Akuyona iphethini eqediwe engaguqulwa ngqo ibe ngumthombo noma ikhodi yomshini . Esikhundleni salokho, yincazelo noma isifanekiso sendlela yokuxazulula inkinga engasetshenziswa ezimeni eziningi ezihlukile. Amaphethini wokuqamba enza izinto ezihlelekile okuhlelekile ongazisebenzisa umxazululi ukuxazulula izinkinga ezivamile lapho kuklanywa isakhiwo noma uhlelo.

Amaphethini wokuklanywa okwenzelwe izinto ngokuvamile akhombisa ubudlelwane nokuxhumana phakathi kwamakilasi noma izinto, ngaphandle kokucacisa amakilasi wokugcina wesicelo noma izinto ezibandakanyekile. Amaphethini asho ukuthi isimo esingaguquki angahle afakelwe izilimi ezisebenzayo, amanye amaphethini angahunyushwa ngokungadingekile ngezilimi ezakhekile ukusekela ukuxazulula inkinga abazama ukuyixazulula, futhi amaphethini aqondiswe entweni awafaneleki ezintweni ezingahambisani nezilwimi zezinto ezenzelwene (Object-oriented)

Amaphethini wokuqamba angabukwa njengendlela ehlelekile yohlelo lokusebenza lwekhompyutha phakathi kwamazinga we- paradigm yohlelo kanye ne- algorithm yekhonkrithi.

Umlando[hlela | Hlela umthombo]

Amaphethini aqala njengomqondo wokwakha ngu -Christopher Alexander ekuqaleni konyaka we-1966 (cf "Isibonelo Semikhonto," JOURNAL OF AIP, Septhemba, 1966, Vol. 32, No. 3, iphe. 273-278). Ngo-1987, uKent Beck noWard Cunningham baqala ukuzama ngomqondo wokusebenzisa amaphethini ezinhlelweni - ngokukhethekile amaphethini ezilimi - futhi bethula imiphumela yabo engqungqutheleni ye- OOPSLA ngalowo nyaka. Eminyakeni elandelayo, u-Beck, uCunningham nabanye balandela lo msebenzi.

Amaphethini okuklama athola ukuthandwa kusayensi yamakhompiyutha ngemuva kokuba incwadi <i id="mwJQ">Design Designs: Elements of Reusable Object-Oriented Software</i> yashicilelwa ngonyaka we-1994 ngababizwa nge- "Gang of Four" (Gamma et al.), Esivame ukufushaniswa ngokuthi "GoF". Ngawo lowo nyaka, kwaqhutshwa inkomfa yokuqala yezilimi ezihleliwe, futhi ngonyaka olandelayo kwasungulwa iPortland Pattern Repository ukuze kube yimibhalo yamaphethini wokuqamba. Isilinganiso sethemu sihlala siyindaba yokuphikisana. Izincwadi eziphawuleka kunhlobo lwephethini yoyilo zifaka:

Yize amakhethini wokuqamba esetshenziswe isikhathi eside, ukwenziwa ngokusemthethweni komqondo wamaphethini wokuqamba kwehle iminyaka eminingi. [1]

Ukwenza[hlela | Hlela umthombo]

Amaphethini wokuqamba angasheshisa inqubo yokuthuthuka ngokunikeza ubuhlakani bokuvivinya obufakazelwe. [2] Idizayini ephumelelayo yesoftware idinga ukucubungula izingqinamba ezingeke zibonakale kuze kamuva ekuqalisweni. Ikhodi esanda kubhalwa phansi ingahlala iba nezinkinga ezicashile ezithathe isikhathi ukuthi zitholwe, izingqinamba kwesinye isikhathi ezingadala izinkinga ezinkulu ngokuhamba kwesikhathi. Ukuphinda usebenzise amaphethini wokuqamba kusiza ukuvikela izindaba ezinjalo ezicashile   , futhi kuthuthukisa ukufundwa kwekhodi kwenzelwa abakhodi nabaklami abajwayele amaphethini.

Ukuze uzuze ukuguquguquka, amaphethini wokuqamba avame ukwethula amazinga ongezekile we- indirection, kwezinye izimo angaphikisana nemiklamo evelayo futhi alimaze ukusebenza kwesicelo.

Ngokwencazelo, iphethini kufanele ihlelwe kabusha ohlelweni ngalunye olusebenzisayo. Njengoba abanye ababhali bebona lokhu njengesinyathelo esibuyela emuva ekusebenzeni kabusha kwesoftware njengoba kunikezwe izakhi, abacwaningi basebenze ukuguqula amaphethini abe yizakhi. UMeyer no-Arnout bakwazile ukuhlinzeka ngezakhi eziphelele noma ngokwengxenye zezingxenye ezimbili kwezintathu zamaphethini abazama ngayo. [3]

Amasu wokuqamba amasoftware kunzima ukuwasebenzisa ebangeni lezinkinga ezibanzi.   Amaphethini wokuqamba anikezela ngezixazululo ezijwayelekile, ezibhalwe ngefomethi engadingi imininingwane eboshelwe enkingeni ethile.

Isakhiwo[hlela | Hlela umthombo]

Amaphethini wokuqamba akhiwa izigaba eziningana (bona §  Imibhalo engezansi). Okuthakazelisa kakhulu yizigaba zoBumbano, Ababambiqhaza kanye nezigaba Zokusebenzisana. Lezi zingxenye zichaza motif design : a prototypical micro-architecture ukuthi onjiniyela bakopisha futhi bazivumelanise nemiklamo yabo ethile ukuxazulula inkinga esetshenziswayo echazwe yiphethini yokuqamba. Isakhiwo esincanyana senhlanganyela seqoqo lezindawo zohlelo (isib, amakilasi, izindlela ...) kanye nobudlelwano bawo. Abathuthukisi basebenzisa iphethini lokuklama ngokwazisa kumiklamo yabo le-prototypical micro-architecture, okusho ukuthi izakhiwo ezincane ezakhiweni zazo zizoba nesakhiwo nenhlangano efana ne-design motif ekhethiwe.

Amaphethini akhethekile wesizinda[hlela | Hlela umthombo]

Kwenziwe futhi imizamo yokuhlanganisa amaphethini wokuqamba ezizindeni ezithile, kufaka phakathi ukusetshenziswa kwamaphethini wokuqamba akhona kanye namaphethini wokuqamba wesizinda esithile. Izibonelo zifaka amaphethini esakhiwo sokusebenziseka komsebenzisi, [4] ukubonwa kolwazi, [5] idizayini evikelekile, [6] "ukusebenziseka okuphephile", ukwakhiwa kwewebhu [7] nokuklama imodeli yebhizinisi. [8]

Izilimi zonyaka zeKhethini Yezinhlelo Zokuhlela [9] zifaka izibonelo eziningi zamaphethini akhethekile wesizinda.

Ukuhlukaniswa nohlu[hlela | Hlela umthombo]

Amaphethini wemiklamo ahlukaniswe ngezigaba ezi-3 ezisuselwa kuhlobo lwenkinga azixazululelayo. Amaphethini wokudala anika amandla okwenza izinto ngokusekelwe indlela edingekayo nangendlela elawulwayo. Amaphethini ezakhiwo akhuluma ngokuhlela amakilasi ahlukene nezinto zokwakha izakhiwo ezinkulu nokunikeza ukusebenza okusha. Ekugcineni, izindlela zokuziphatha zimayelana nokuhlonza amaphethini wokuxhumana ajwayelekile phakathi kwezinto futhi aqaphele lamaphethini.

Amaphethini wokudala[hlela | Hlela umthombo]

Igama Incazelo Kumaphethini Okuklama KuKhodi Qeda [10] Okunye
Imboni Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ibhuloho Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Inhlanganisela Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umhlobisi Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Into yokunwebeka Template:No| Template:No| Template:Yes
I-facade Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
I-Flyweight Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isilawuli sangaphambili Template:No| Template:No| Template:Yes
Umaka Template:No| Template:No| Template:Yes
Module Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ummeli Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Iwele [11] Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A

Amaphethini ezakhiwo[hlela | Hlela umthombo]

Igama Incazelo Kumaphethini Okuklama KuKhodi Qeda [10] Okunye
Adapter, Wrapper, noma Translator Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ibhuloho Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Inhlanganisela Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umhlobisi Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Into yokunwebeka Template:No| Template:No| Template:Yes
I-facade Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
I-Flyweight Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isilawuli sangaphambili Template:No| Template:No| Template:Yes
Umaka Template:No| Template:No| Template:Yes
Module Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ummeli Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Iwele [12] Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A

Amaphethini wokuziphatha[hlela | Hlela umthombo]

Igama Incazelo Kumaphethini Okuklama KuKhodi Qeda [10] Okunye
Ibhodi emnyama Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Uhlobo lomthwalo wemfanelo Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umyalo Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umhumushi Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
I-Iterator Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umlamuli Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
UMemento Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Into engekho Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umbukeli noma Shicilela / bhalisa Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Inceku Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ukucaciswa Template:No| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isimo Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isu Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Indlela yesifanekiso Template:Yes| Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isivakashi Template:Yes| Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Igama Incazelo Ku- POSA2 [13] Okunye
Into esebenzayo Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ukungabaza Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Izici zokubopha Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ikhompiyutha ekhompyutheni Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Kuhlolwe kukabili Yehlisa isendlalelo sokuthola ukhiye ngokuhlola kuqala inqubomgomo yokukhiya ('icebo lokukhiya') ngendlela engaphephile; kuphela uma lokho kuphumelela ukwenza inqubo yangempela yokukhiya.

Kungavikeleka uma kusetshenziswa ezinye izinhlanganisela zolimi / zehadiwe. Ngakho-ke kwesinye isikhathi kungabhekwa njengephethini le- anti .

Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Umcimbi osuselwa kumcimbi Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ukumiswa okuqashiwe Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Joyina Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Khiya Template:No| Template:Yes
Imodeli yokwakheka kwemilayezo Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Qapha into Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
I-Reactor Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ilokhi yokubhala Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isheduli Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Ichibi lamanzi Template:No| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A
Isitoreji esinqunyelwe i-Thread Template:Yes| style="background: #ececec; color: grey; vertical-align: middle; text-align: center; " class="table-na" | N/A

Imibhalo[hlela | Hlela umthombo]

Imibhalo yephethini lokuklama ichaza umongo lapho iphethini isetshenziswa khona, amandla ngaphakathi komongo iphethini elifuna ukuwaxazulula, kanye nekhambi eliphakanyisiwe. [17] Akukho fomethi eyodwa, ejwayelekile yamaphethini wokuklama. Esikhundleni salokho, izinhlobo ezahlukahlukene zisetshenziswe ngababhali bephethini abahlukile. Kodwa-ke, ngokusho kukaMartin Fowler, izinhlobo ezithile zamaphethini ziye zaziwa kakhulu kunabanye, futhi ngenxa yalokho zaba ngamaphuzu okuqala ajwayelekile emizamo emisha yokubhala iphethini. [18] Isibonelo esisodwa sefomethi yemibhalo evame ukusetshenziswa yileso esisetshenziswa u- Erich Gamma, uRichard Helm, uRalph Johnson, noJohn Vlissides encwadini yabo Designamps . Inezingxenye ezilandelayo:

  • Igama Lephethini Nokwehlukanisa: Igama elichazayo nelingafani elisiza ekuboneni nasekubhekiseleni kuphethini.
  • Inhloso: Ukuchazwa kwenhloso ngemuva kwephethini nesizathu sokuyisebenzisa.
  • Yaziwa Futhi ngokuthi: Amanye amagama wephethini.
  • Ukugqugquzela (Amandla): Isimo esinezinkinga kanye nomongo lapho leli phethini lingasetshenziswa khona.
  • Ukusebenza: Izimo lapho le ndlela isetshenziswa khona; umongo wephethini.
  • Ukwakheka: Ukuboniswa okucacisayo kwephethini. Imidwebo yekilasi kanye nemidwebo yekusebenza ingasebenziselwa lenjongo.
  • Ababambiqhaza: Uhlu lwamakilasi nezinto ezisetshenziswe kuphethini nezindima zawo ekwakhiweni.
  • Ukusebenzisana: Incazelo yokuthi amakilasi nezinto ezisetshenziswe kuphethini zisebenzisana kanjani.
  • Imiphumela: Incazelo yemiphumela, imiphumela emibi, nokuhweba okukhohlakele okubangelwa kusetshenziswa iphethini.
  • Ukuqaliswa: Ukuchazwa kokusetshenziswa kwephethini; ingxenye yesisombululo sephathini.
  • Ikhodi Eyisibonelo: Umzekeliso wendlela iphethini elingasetshenziswa ngayo olimini lwezinhlelo.
  • Ukusetshenziswa okwaziwayo: Izibonelo zokusetshenziswa kwangempela kwephethini.
  • Amaphethini ahlobene: Amanye amaphethini anobuhlobo obuthile nephethini; ukuxoxa ngomehluko phakathi kwephethini namaphethini afanayo.

Ukugxekwa[hlela | Hlela umthombo]

Kuqashelwe ukuthi amaphethini wokuqamba angaba nje uphawu lokuthi ezinye izici zishoda ngolimi olunikeziwe lwezinhlelo ( iJava noma i- C ++ ngokwesibonelo). UPeter Norvig ukhombisa ukuthi amaphethini ayi-16 kwayi -23 asencwadini ye- Design Patterns (ebhekiswe kakhulu ku-C ++) ayenziwa lula noma aqedwe (ngosizo oluqondile lolimi) eLisp noma iDylan . Ukubukwa okuhlobene nakho kwenziwa nguHannemann noKiczales abasebenzise amaphethini amaningi wokuqamba angama-23 besebenzisa ulimi olususelwa kuzinhlelo (AspectJ) futhi bakhombisa ukuthi ukuncika kwezinga lekhodi kususwe ekusetshenzisweni kwamaphethini wokuqamba we-17 kwayi-23 nokuthi isisekelo-esigxile izinhlelo zingenza lula ukwenziwa kwamaphethini wokuqamba. Template:Ifsubst Bheka futhi nendatshana kaPaul Graham ethi "Revenge of the Nerds".

Ukusetshenziswa okungafanele kwamaphethini kungandisa ukuxaka okungadingekile. [19]

  1. Baroni, Aline Lúcia; Guéhéneuc, Yann-Gaël; Albin-Amiot, Hervé. Design Patterns Formalization. École Nationale Supérieure des Techniques Industrielles et des Mines de Nantes. 
  2. Bishop, Judith. "C# 3.0 Design Patterns: Use the Power of C# 3.0 to Solve Real-World Problems". C# Books from O'Reilly Media. http://msdn.microsoft.com/en-us/vstudio/ff729657. Retrieved 2012-05-15. "If you want to speed up the development of your .NET applications, you're ready for C# design patterns -- elegant, accepted and proven ways to tackle common programming problems." 
  3. Meyer, Bertrand; Arnout, Karine. Componentization: The Visitor Example. 
  4. Laakso, Sari A.. "Collection of User Interface Design Patterns". University of Helsinki, Dept. of Computer Science. http://www.cs.helsinki.fi/u/salaakso/patterns/index.html. Retrieved 2008-01-31. 
  5. Heer, J.. Software Design Patterns for Information Visualization. http://vis.berkeley.edu/papers/infovis_design_patterns/. 
  6. Dougherty, Chad. Secure Design Patterns. Software Engineering Institute. http://www.cert.org/archive/pdf/09tr010.pdf. 
  7. "Yahoo! Design Pattern Library". http://developer.yahoo.com/ypatterns/. Retrieved 2008-01-31. 
  8. "How to design your Business Model as a Lean Startup?". http://torgronsund.wordpress.com/2010/01/06/lean-startup-business-model-pattern/. Retrieved 2010-01-06. 
  9. Pattern Languages of Programming, Conference proceedings (annual, 1994—)
  10. 10.0 10.1 10.2 McConnell, Steve (June 2004). "Design in Construction". Code Complete (2nd ed.). Microsoft Press. p. 104. ISBN 978-0-7356-1967-8. "Table 5.1 Popular Design Patterns" 
  11. "Twin – A Design Pattern for Modeling Multiple Inheritance". 
  12. "Twin – A Design Pattern for Modeling Multiple Inheritance". 
  13. Schmidt, Douglas C.; Stal, Michael; Rohnert, Hans; Buschmann, Frank. Pattern-Oriented Software Architecture, Volume 2: Patterns for Concurrent and Networked Objects. John Wiley & Sons. ISBN 978-0-471-60695-6. 
  14. Binding Properties
  15. Nagel, Christian; Evjen, Bill; Glynn, Jay; Watson, Karli (2008). Professional C# 2008. Wiley. ISBN 978-0-470-19137-8. 
  16. Lock Pattern
  17. Gabriel, Dick. "A Pattern Definition". Archived from the original on 2007-02-09. https://web.archive.org/web/20070209224120/http://hillside.net/patterns/definition.html. Retrieved 2007-03-06. 
  18. Fowler, Martin. "Writing Software Patterns". http://www.martinfowler.com/articles/writingPatterns.html. Retrieved 2007-03-06. 
  19. McConnell, Steve. Code Complete: A Practical Handbook of Software Construction, 2nd Edition. p. 105.