首頁(yè) > 計(jì)算機(jī)網(wǎng)絡(luò) >
編程語(yǔ)言與程序設(shè)計(jì)
> Hands-On Dependency Injection in Go最新章節(jié)目錄
舉報(bào)

會(huì)員
Hands-On Dependency Injection in Go
Hands-OnDependencyInjectioninGotakesyouonajourney,teachingyouaboutrefactoringexistingcodetoadoptdependencyinjection(DI)usingvariousmethodsavailableinGo.Ofthesixmethodsintroducedinthisbook,someareconventional,suchasconstructorormethodinjection,andsomeunconventional,suchasjust-in-timeorconfiginjection.Eachmethodisexplainedindetail,focusingontheirstrengthsandweaknesses,andisfollowedwithastep-by-stepexampleofhowtoapplyit.Withplentyofexamples,youwilllearnhowtoleverageDItotransformcodeintosomethingsimpleandflexible.Youwillalsodiscoverhowtogenerateandleveragethedependencygraphtospotandeliminateissues.Throughoutthebook,youwilllearntoleverageDIincombinationwithteststubsandmockstotestotherwisetrickyorimpossiblescenarios.Hands-OnDependencyInjectioninGotakesapragmaticapproachandfocusesheavilyonthecode,userexperience,andhowtoachievelong-termbenefitsthroughincrementalchanges.Bytheendofthisbook,youwillhaveproducedcleancodethat’seasytotest.
目錄(236章)
倒序
- coverpage
- Title Page
- Dedication
- About Packt
- Why subscribe?
- Packt.com
- Contributors
- About the author
- About the reviewer
- Packt is searching for authors like you
- Preface
- Who this book is for
- What this book covers
- To get the most out of this book
- Download the example code files
- Download the color images
- Conventions used
- Get in touch
- Reviews
- Never Stop Aiming for Better
- Technical requirements
- Why does DI matter?
- So how do I define DI?
- Code smells that indicate you might need DI
- Code bloat
- Resistance to change
- Wasted effort
- Tight coupling
- Healthy skepticism
- A quick word about idiomatic Go
- Leave your baggage at the door
- Summary
- Questions
- Further reading
- SOLID Design Principles for Go
- Technical requirements
- Single responsibility principle (SRP)
- How does this relate to DI?
- What does this mean for Go?
- Go interfaces structs and functions
- Go packages
- Open/closed principle (OCP)
- How does this relate to DI?
- What does this mean for Go?
- Liskov substitution principle (LSP)
- How does this relate to DI?
- What does this mean for Go?
- Interface segregation principle (ISP)
- How does this relate to DI?
- What does this mean for Go?
- Dependency inversion principle (DIP)
- How does this relate to DI?
- What does this mean for Go?
- Summary
- Questions
- Further reading
- Coding for User Experience
- Technical requirements
- Optimizing for humans
- What does user experience mean for Go code?
- Start with simple – get complicated only when you must
- Apply just enough abstraction
- Follow industry team and language conventions
- Export only what you must
- Aggressively apply the single responsibility principle
- Discovering a good user experience
- Who is the user?
- What are your users capable of?
- Why do users want to use your code?
- How do they expect to use it?
- When to compromise
- Final thoughts on coding for user experience
- A security blanket named unit tests
- So why do I write unit tests?
- What should I test?
- Table-driven tests
- Stubs
- Mocks
- Test-induced damage
- Warning signs of test-induced damage
- Parameters config options or outputs that only exist because of tests
- Parameters that cause or are caused by leaky abstractions
- Publishing mocks in production code
- Excessive test coverage
- Visualizing your package dependencies with Godepgraph
- Installing the tools
- Generating a dependency graph
- Interpreting the dependency graph
- Summary
- Questions
- Introduction to the ACME Registration Service
- Technical requirements
- Goals for our system
- High readability
- High testability
- Low coupling
- Final thoughts on goals
- Introduction to our system
- Software architecture
- Known issues
- Testability
- Duplication of effort
- Lack of isolation in tests
- High coupling between the data and REST packages
- High coupling with the config package
- Downstream currency service
- Summary
- Questions
- Dependency Injection with Monkey Patching
- Technical requirements
- Monkey magic!
- Advantages of monkey patching
- Applying monkey patching
- Introducing SQLMock
- Monkey patching with SQLMock
- Testing error handling
- Reducing test bloat with table-driven tests
- Monkey patching between packages
- When the magic fades
- Summary
- Questions
- Further reading
- Dependency Injection with Constructor Injection
- Technical requirements
- Constructor injection
- Addressing the duck in the room
- Advantages of constructor injection
- Applying constructor injection
- Decoupling from the dependency
- Building the constructor
- Improving test scenario coverage
- Validating our improvements with the dependency graph
- Disadvantages of constructor injection
- Summary
- Questions
- Dependency Injection with Method Injection
- Technical requirements
- Method injection
- Advantages of method injection
- Applying method injection
- A quick recap
- Stopping short
- Applying method injection to the data package
- Applying method injection to the exchange package
- Applying method injection to the model layer (the Get List and Register packages)
- Applying the method injection of context to the REST package
- Latency budgets
- Disadvantages of method injection
- Summary
- Questions
- Dependency Injection by Config
- Technical requirements
- Config injection
- Advantages of config injection
- Applying config injection
- Applying config injection to the model layer
- Applying config injection to the data package
- Applying config injection to the exchange package
- Boundary tests
- Disadvantages of config injection
- Summary
- Questions
- Just-in-Time Dependency Injection
- Technical requirements
- JIT injection
- Advantages of JIT injection
- Applying JIT injection
- Private dependencies
- Unit test coverage
- Coverage and dependency graph
- Chasing away the monkeys
- Optional public dependencies
- Disadvantages of JIT injection
- Summary
- Questions
- Off-the-Shelf Injection
- Technical requirements
- Off-the-shelf injection with Wire
- Introducing providers
- Understanding injectors
- Adopting provider sets
- Advantages of off-the-shelf injection
- Applying off-the-shelf injection
- Adopting Google Wire
- API regression tests
- Disadvantages of off-the-shelf injection
- Summary
- Questions
- Curb Your Enthusiasm
- Technical requirements
- DI induced damage
- A long constructor parameter list
- Injecting an object when config would do
- Needless indirection
- Service locator
- Premature future-proofing
- Mocking HTTP requests
- Mocking an HTTP request with DI
- Mocking HTTP requests with config
- Unnecessary injection
- Summary
- Questions
- Reviewing Our Progress
- Technical requirements
- Overview of the improvements
- Global singletons
- High coupling with the config package
- Removing the dependence on upstream service
- Stopping short and latency budgets
- Simplified dependency creation
- Coupling and extensibility
- Review of the dependency graph
- Review of test coverage and testability
- Test coverage
- Starting a new service with DI
- The user experience
- Code structure
- Cross-cutting concerns
- Designing from outside-in
- Summary
- Questions
- Assessment
- Chapter 1 Never Stop Aiming for Better
- Chapter 2 SOLID Design Principles for Go
- Chapter 3 Coding for User Experience
- Chapter 4 Introduction to the ACME Registration Service
- Chapter 5 Dependency Injection with Monkey Patching
- Chapter 6 Dependency Injection with Constructor Injection
- Chapter 7 Dependency Injection with Method Injection
- Chapter 8 Dependency Injection by Config
- Chapter 9 Just-in-Time Dependency Injection
- Chapter 10 Off-the-Shelf Injection
- Chapter 11 Curbing Your Enthusiasm
- Chapter 12 Reviewing Our Progress
- Other Books You May Enjoy
- Leave a review - let other readers know what you think 更新時(shí)間:2021-06-10 19:18:21
推薦閱讀
- 演進(jìn)式架構(gòu)(原書(shū)第2版)
- Learning Neo4j
- Mastering Natural Language Processing with Python
- Vue.js快跑:構(gòu)建觸手可及的高性能Web應(yīng)用
- The Computer Vision Workshop
- Reactive Programming With Java 9
- Drupal 8 Configuration Management
- 自然語(yǔ)言處理Python進(jìn)階
- Go并發(fā)編程實(shí)戰(zhàn)
- Haskell Data Analysis Cookbook
- Getting Started with Eclipse Juno
- C語(yǔ)言程序設(shè)計(jì)習(xí)題與實(shí)驗(yàn)指導(dǎo)
- Akka入門(mén)與實(shí)踐
- PHP+MySQL Web應(yīng)用開(kāi)發(fā)教程
- Responsive Web Design with jQuery
- Less Web Development Cookbook
- Mastering Data Analysis with R
- Visual C++程序開(kāi)發(fā)范例寶典
- 中小企業(yè)網(wǎng)站建設(shè)與管理(靜態(tài)篇)
- Testing Practitioner Handbook
- Advanced Analytics with R and Tableau
- HTML5 for Flash Developers
- C#程序設(shè)計(jì)經(jīng)典300例
- Python自動(dòng)化測(cè)試實(shí)戰(zhàn)
- C#程序設(shè)計(jì)教程
- Magento Extensions Development
- Visual Basic程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)
- 孩子趣味學(xué)編程之Scratch篇
- C語(yǔ)言程序設(shè)計(jì)習(xí)題解析
- Building Web Apps with Spring 5 and Angular