舉報(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
推薦閱讀
- Flask Web全棧開發(fā)實(shí)戰(zhàn)
- 新編Visual Basic程序設(shè)計(jì)上機(jī)實(shí)驗(yàn)教程
- Cross-platform Desktop Application Development:Electron,Node,NW.js,and React
- Mastering Ubuntu Server
- HDInsight Essentials(Second Edition)
- Windows內(nèi)核編程
- 軟件供應(yīng)鏈安全:源代碼缺陷實(shí)例剖析
- Statistical Application Development with R and Python(Second Edition)
- LabVIEW虛擬儀器程序設(shè)計(jì)從入門到精通(第二版)
- R用戶Python學(xué)習(xí)指南:數(shù)據(jù)科學(xué)方法
- Python Interviews
- Emotional Intelligence for IT Professionals
- Backbone.js Testing
- 創(chuàng)新工場講AI課:從知識(shí)到實(shí)踐
- 高質(zhì)量程序設(shè)計(jì)指南:C++/C語言
- Java EE程序設(shè)計(jì)與開發(fā)實(shí)踐教程
- Mastering Puppet(Second Edition)
- Microsoft Hyper-V PowerShell Automation
- 一個(gè)APP的誕生:從零開始設(shè)計(jì)你的手機(jī)應(yīng)用
- Metasploit for Beginners
- Java高級(jí)特性編程及實(shí)戰(zhàn)
- Three.js開發(fā)指南
- 寫給風(fēng)控師的實(shí)操手冊(cè)(全2冊(cè))
- 劍指JavaScript:核心原理與應(yīng)用實(shí)踐
- Java高并發(fā)與集合框架:JCF和JUC源碼分析與實(shí)現(xiàn)
- Selenium 1.0 Testing Tools: Beginner's Guide
- Learning Boost C++ Libraries
- C#深入詳解
- 小學(xué)生Scratch創(chuàng)意編程(視頻教學(xué)版)
- C語言程序設(shè)計(jì)實(shí)驗(yàn)指導(dǎo)與習(xí)題精選