Design patterns for the Go programming language - GitHub

文章推薦指數: 80 %
投票人數:10人

Creational design patterns are design patterns that deal with object creation mechanisms, trying to create objects in a manner suitable to the situation. The ... Skiptocontent {{message}} bvwells / go-patterns Public Notifications Star 482 Fork 62 DesignpatternsfortheGoprogramminglanguage bvwells.github.io/go-patterns/ MITLicense 482 stars 62 forks Star Notifications Code Issues 4 Pullrequests 0 Actions Projects 0 Wiki Security Insights More Code Issues Pullrequests Actions Projects Wiki Security Insights master Branches Tags Couldnotloadbranches Nothingtoshow Loading {{refName}} default Couldnotloadtags Nothingtoshow {{refName}} default Loading 1 branch 2 tags Code Loading Latestcommit bvwells AdddebuginformationtotravisCIbuild … cda58ba Oct28,2021 AdddebuginformationtotravisCIbuild cda58ba Gitstats 176 commits Files Permalink Failedtoloadlatestcommitinformation. Type Name Latestcommitmessage Committime behavioral     creational     structural     .gitignore     .golangci.yaml     .travis.yml     LICENSE     README.md     _config.yml     appveyor.yml     go.mod     go.sum     jigsaw.png     patterns.go     test.sh     Viewcode DesignPatternsforGo DesignPatterns Creational Structural Behavioral GoVersionsSupported README.md DesignPatternsforGo DesignpatternsfortheGoprogramminglanguage. import"github.com/bvwells/go-patterns" Toinstallthepackagesonyoursystem, $goget-ugithub.com/bvwells/go-patterns/... Documentationandexamplesareavailableathttps://pkg.go.dev/github.com/bvwells/go-patterns?tab=overview DesignPatterns Creational Structural Behavioral GoVersionsSupported DesignPatterns Pattern Package Description Creational creational Creationaldesignpatternsaredesignpatternsthatdealwithobjectcreationmechanisms,tryingtocreateobjectsinamannersuitabletothesituation.Thebasicformofobjectcreationcouldresultindesignproblemsorinaddedcomplexitytothedesign.Creationaldesignpatternssolvethisproblembysomehowcontrollingthisobjectcreation. Structural structural Structuraldesignpatternsaredesignpatternsthateasethedesignbyidentifyingasimplewaytorealizerelationshipsbetweenentities. Behavioral behavioral Behavioraldesignpatternsaredesignpatternsthatidentifycommoncommunicationpatternsbetweenobjectsandrealizethesepatterns.Bydoingso,thesepatternsincreaseflexibilityincarryingoutthiscommunication. Creational Name Description AbstractFactory Provideaninterfaceforcreatingfamiliesofrelatedordependentobjectswithoutspecifyingtheirconcreteclasses. Builder Separatetheconstructionofacomplexobjectfromitsrepresentation,allowingthesameconstructionprocesstocreatevariousrepresentations. FactoryMethod Defineaninterfaceforcreatingasingleobject,butletsubclassesdecidewhichclasstoinstantiate.FactoryMethodletsaclassdeferinstantiationtosubclasses. ObjectPool Avoidexpensiveacquisitionandreleaseofresourcesbyrecyclingobjectsthatarenolongerinuse.Canbeconsideredageneralisationofconnectionpoolandthreadpoolpatterns. Prototype Specifythekindsofobjectstocreateusingaprototypicalinstance,andcreatenewobjectsfromthe'skeleton'ofanexistingobject,thusboostingperformanceandkeepingmemoryfootprintstoaminimum. Singleton Ensureaclasshasonlyoneinstance,andprovideaglobalpointofaccesstoit. Structural Name Description Adapter Converttheinterfaceofaclassintoanotherinterfaceclientsexpect.Anadapterletsclassesworktogetherthatcouldnototherwisebecauseofincompatibleinterfaces.Theenterpriseintegrationpatternequivalentisthetranslator. Bridge Decoupleanabstractionfromitsimplementationallowingthetwotovaryindependently. Composite Composeobjectsintotreestructurestorepresentpart-wholehierarchies.Compositeletsclientstreatindividualobjectsandcompositionsofobjectsuniformly. Decorator Attachadditionalresponsibilitiestoanobjectdynamicallykeepingthesameinterface.Decoratorsprovideaflexiblealternativetosubclassingforextendingfunctionality. Facade Provideaunifiedinterfacetoasetofinterfacesinasubsystem.Facadedefinesahigher-levelinterfacethatmakesthesubsystemeasiertouse. Flyweight Usesharingtosupportlargenumbersofsimilarobjectsefficiently. Proxy Provideasurrogateorplaceholderforanotherobjecttocontrolaccesstoit. Behavioral Name Description ChainofResponsibility Avoidcouplingthesenderofarequesttoitsreceiverbygivingmorethanoneobjectachancetohandletherequest.Chainthereceivingobjectsandpasstherequestalongthechainuntilanobjecthandlesit. Command Encapsulatearequestasanobject,therebyallowingfortheparameterizationofclientswithdifferentrequests,andthequeuingorloggingofrequests.Italsoallowsforthesupportofundoableoperations. Interpreter Givenalanguage,definearepresentationforitsgrammaralongwithaninterpreterthatusestherepresentationtointerpretsentencesinthelanguage. Iterator Provideawaytoaccesstheelementsofanaggregateobjectsequentiallywithoutexposingitsunderlyingrepresentation. Mediator Defineanobjectthatencapsulateshowasetofobjectsinteract.Mediatorpromotesloosecouplingbykeepingobjectsfromreferringtoeachotherexplicitly,anditallowstheirinteractiontovaryindependently. Memento Withoutviolatingencapsulation,captureandexternalizeanobject'sinternalstateallowingtheobjecttoberestoredtothisstatelater. Observer Defineaone-to-manydependencybetweenobjectswhereastatechangeinoneobjectresultsinallitsdependentsbeingnotifiedandupdatedautomatically. State Allowanobjecttoalteritsbehaviorwhenitsinternalstatechanges.Theobjectwillappeartochangeitsclass. Strategy Defineafamilyofalgorithms,encapsulateeachone,andmaketheminterchangeable.Strategyletsthealgorithmvaryindependentlyfromclientsthatuseit. TemplateMethod Definetheskeletonofanalgorithminanoperation,deferringsomestepstosubclasses.Templatemethodletssubclassesredefinecertainstepsofanalgorithmwithoutchangingthealgorithm'sstructure. Visitor Representanoperationtobeperformedontheelementsofanobjectstructure.Visitorletsanewoperationbedefinedwithoutchangingtheclassesoftheelementsonwhichitoperates. GoVersionsSupported ThemostrecentmajorversionofGoissupported.Youcanseewhichversionsare currentlysupportedbylookingatthelinesfollowinggo:in .travis.yml. About DesignpatternsfortheGoprogramminglanguage bvwells.github.io/go-patterns/ Topics go golang patterns idioms design-patterns Resources Readme License MITLicense Releases 2 Newrelease Latest Jul14,2020 +1release Packages0 Nopackagespublished Contributors2 bvwells BenWells erkanzileli ErkanZileli Languages Go 99.5% Shell 0.5% Youcan’tperformthatactionatthistime. Yousignedinwithanothertaborwindow.Reloadtorefreshyoursession. Yousignedoutinanothertaborwindow.Reloadtorefreshyoursession.



請為這篇文章評分?