Design patterns for the Go programming language - GitHub
文章推薦指數: 80 %
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.
延伸文章資訊
- 1senghoo/golang-design-pattern: 设计模式Golang实现 - GitHub
设计模式Golang实现-《研磨设计模式》读书笔记. Contribute to senghoo/golang-design-pattern development by creating an...
- 2Curated list of Go design patterns, recipes and idioms - GitHub
Go Patterns build-status awesome license · Creational Patterns · Structural Patterns · Behavioral...
- 3enix223/go-design-pattern - GitHub
design pattern for golang. Contribute to enix223/go-design-pattern development by creating an acc...
- 4PacktPublishing/Go-Design-Patterns: This is the code ... - GitHub
This is the code repository for Go Design Patterns, published by Packt. It contains all the suppo...
- 5Design patterns in golang - GitHub
Implementation of design patterns in Golang. Contribute to ismayilmalik/golang-design-patterns de...