Design Patterns in Go - Refactoring.Guru
文章推薦指數: 80 %
The Catalog of Go Examples · Creational Patterns · Abstract Factory · Builder · Factory Method · Prototype · Singleton · Structural Patterns · Adapter. Hey,Ihavejustreducedthepriceforallproducts.Let'sprepareourprogrammingskillsforthepost-COVIDera.Checkitout» DesignPatternsinGo TheCatalogofGoExamples CreationalPatterns AbstractFactory Letsyouproducefamiliesofrelatedobjectswithoutspecifyingtheirconcreteclasses. Mainarticle Codeexample Builder Letsyouconstructcomplexobjectsstepbystep.Thepatternallowsyoutoproducedifferenttypesandrepresentationsofanobjectusingthesameconstructioncode. Mainarticle Codeexample FactoryMethod Providesaninterfaceforcreatingobjectsinasuperclass,butallowssubclassestoalterthetypeofobjectsthatwillbecreated. Mainarticle Codeexample Prototype Letsyoucopyexistingobjectswithoutmakingyourcodedependentontheir classes. Mainarticle Codeexample Singleton Letsyouensurethataclasshasonlyoneinstance,whileprovidingaglobalaccesspointtothisinstance. Mainarticle Codeexample StructuralPatterns Adapter Allowsobjectswithincompatibleinterfacestocollaborate. Mainarticle Codeexample Bridge Letsyousplitalargeclassorasetofcloselyrelatedclassesintotwoseparatehierarchies—abstractionandimplementation—whichcanbedevelopedindependentlyofeachother. Mainarticle Codeexample Composite Letsyoucomposeobjectsintotreestructuresandthenworkwiththesestructuresasiftheywereindividualobjects. Mainarticle Codeexample Decorator Letsyouattachnewbehaviorstoobjectsbyplacingtheseobjectsinsidespecialwrapperobjectsthatcontainthebehaviors. Mainarticle Codeexample Facade Providesasimplifiedinterfacetoalibrary,aframework,oranyothercomplexsetofclasses. Mainarticle Codeexample Flyweight LetsyoufitmoreobjectsintotheavailableamountofRAMbysharingcommonpartsofstatebetweenmultipleobjectsinsteadofkeepingallofthedataineachobject. Mainarticle Codeexample Proxy Letsyouprovideasubstituteorplaceholderforanotherobject.Aproxycontrolsaccesstotheoriginalobject,allowingyoutoperformsomethingeitherbeforeoraftertherequestgetsthroughtotheoriginalobject. Mainarticle Codeexample BehavioralPatterns ChainofResponsibility Letsyoupassrequestsalongachainofhandlers.Uponreceivingarequest,eachhandlerdecideseithertoprocesstherequestortopassittothenexthandlerinthechain. Mainarticle Codeexample Command Turnsarequestintoastand-aloneobjectthatcontainsallinformationabouttherequest.Thistransformationletsyoupassrequestsasamethodarguments,delayorqueuearequest'sexecution,andsupportundoableoperations. Mainarticle Codeexample Iterator Letsyoutraverseelementsofacollectionwithoutexposingitsunderlyingrepresentation(list,stack,tree,etc.). Mainarticle Codeexample Mediator Letsyoureducechaoticdependenciesbetweenobjects.Thepatternrestrictsdirectcommunicationsbetweentheobjectsandforcesthemtocollaborateonlyviaamediatorobject. Mainarticle Codeexample Memento Letsyousaveandrestorethepreviousstateofanobjectwithoutrevealingthedetailsofitsimplementation. Mainarticle Codeexample Observer Letsyoudefineasubscriptionmechanismtonotifymultipleobjectsaboutanyeventsthathappentotheobjectthey'reobserving. Mainarticle Codeexample State Letsanobjectalteritsbehaviorwhenitsinternalstatechanges.Itappearsasiftheobjectchangeditsclass. Mainarticle Codeexample Strategy Letsyoudefineafamilyofalgorithms,puteachofthemintoaseparateclass,andmaketheirobjectsinterchangeable. Mainarticle Codeexample TemplateMethod Definestheskeletonofanalgorithminthesuperclassbutletssubclassesoverridespecificstepsofthealgorithmwithoutchangingitsstructure. Mainarticle Codeexample Visitor Letsyouseparatealgorithmsfromtheobjectsonwhichtheyoperate. Mainarticle Codeexample Facebook Twitter Language English Español Français Polski PortuguêsBrasileiro Русский Українська 中文 Contactus Login EnglishEnglish EspañolEspañol FrançaisFrançais PolskiPolski PortuguêsBrasileiroPortuguês-Br РусскийРусский УкраїнськаУкраїнська 中文中文 PremiumContent DesignPatternseBook RefactoringCourse Refactoring WhatisRefactoring Cleancode Technicaldebt Whentorefactor Howtorefactor Catalog CodeSmells Bloaters LongMethod LargeClass PrimitiveObsession LongParameterList DataClumps Object-OrientationAbusers SwitchStatements TemporaryField RefusedBequest AlternativeClasseswithDifferentInterfaces ChangePreventers DivergentChange ShotgunSurgery ParallelInheritanceHierarchies Dispensables Comments DuplicateCode LazyClass DataClass DeadCode SpeculativeGenerality Couplers FeatureEnvy InappropriateIntimacy MessageChains MiddleMan OtherSmells IncompleteLibraryClass Refactorings ComposingMethods ExtractMethod InlineMethod ExtractVariable InlineTemp ReplaceTempwithQuery SplitTemporaryVariable RemoveAssignmentstoParameters ReplaceMethodwithMethodObject SubstituteAlgorithm MovingFeaturesbetweenObjects MoveMethod MoveField ExtractClass InlineClass HideDelegate RemoveMiddleMan IntroduceForeignMethod IntroduceLocalExtension OrganizingData SelfEncapsulateField ReplaceDataValuewithObject ChangeValuetoReference ChangeReferencetoValue ReplaceArraywithObject DuplicateObservedData ChangeUnidirectionalAssociationtoBidirectional ChangeBidirectionalAssociationtoUnidirectional ReplaceMagicNumberwithSymbolicConstant EncapsulateField EncapsulateCollection ReplaceTypeCodewithClass ReplaceTypeCodewithSubclasses ReplaceTypeCodewithState/Strategy ReplaceSubclasswithFields SimplifyingConditionalExpressions DecomposeConditional ConsolidateConditionalExpression ConsolidateDuplicateConditionalFragments RemoveControlFlag ReplaceNestedConditionalwithGuardClauses ReplaceConditionalwithPolymorphism IntroduceNullObject IntroduceAssertion SimplifyingMethodCalls RenameMethod AddParameter RemoveParameter SeparateQueryfromModifier ParameterizeMethod ReplaceParameterwithExplicitMethods PreserveWholeObject ReplaceParameterwithMethodCall IntroduceParameterObject RemoveSettingMethod HideMethod ReplaceConstructorwithFactoryMethod ReplaceErrorCodewithException ReplaceExceptionwithTest DealingwithGeneralization PullUpField PullUpMethod PullUpConstructorBody PushDownMethod PushDownField ExtractSubclass ExtractSuperclass ExtractInterface CollapseHierarchy FormTemplateMethod ReplaceInheritancewithDelegation ReplaceDelegationwithInheritance DesignPatterns WhatisaPattern What’sadesignpattern? Historyofpatterns WhyshouldIlearnpatterns? Criticismofpatterns Classificationofpatterns Catalog CreationalPatterns FactoryMethod AbstractFactory Builder Prototype Singleton StructuralPatterns Adapter Bridge Composite Decorator Facade Flyweight Proxy BehavioralPatterns ChainofResponsibility Command Iterator Mediator Memento Observer State Strategy TemplateMethod Visitor CodeExamples C# C++ Go Java PHP Python Ruby Swift TypeScript Login Contactus
延伸文章資訊
- 1[Golang] Design Pattern | PJCHENder 未整理筆記
在Go 中需要為某些struct (通常是一些設定),可以同時有預設值的,但有希望可以客製化設定時,可以使用這個方式:.
- 2Common anti-patterns in Go - DeepSource
A list of anti-patterns you should avoid while writing code in Golang. Insights Go. Header image....
- 3Golang Concurrency Pattern - iT 邦幫忙
Go劍復國-30天導入Golang 系列第26 篇 ... 所謂的CPU & MEM 上限,所以也就意味著goroutine 不能無窮無境的開,那今天就來討論Concurrency Patter...
- 4一起幫忙解決難題,拯救IT 人的一天
Go Design Patterns. Hey! Go Design Patterns 系列第1 篇. 髒桶子York Lin. 3 個月前‧ 190 瀏覽. 2. 大家好,本系列文章探討經典D...
- 5Design Patterns in Go | Udemy
This course in particular covers patterns with the use of: The latest versions of the Go programm...