Dependency Injection in C++Bloomberg 1© 2024 Bloomberg Finance L.P. All rights reserved. Dependency Injection in C++: A Practical Guide CppCon 2024 September 18, 2024 Pete Muldoon Senior Engineering LeadBloomberg 4 Questions it8 Bloomberg Where will we be going ? • Talk will be about inserting meaningful Dependency Injection in applications • Using various DI methods to achieve functionality swapping / instrumentation (or just giving up) • Talk is rooted in a real-world system not theory9 Bloomberg Dependency Injection : 1. Decreases coupling between functionality blocks 2. Used to make a class/function independent0 码力 | 106 页 | 1.76 MB | 6 月前3
1.3 Go practices in TiDB 姚维PingCAP wink@pingcap.com Agenda ● How to build a stable database ○ Schrodinger-test platform ○ Failpoint injection ○ Goroutine-leak detection ● Optimization ○ Chunk vs interface{} ○ Vectorized execution TiDB the Cat is dead, and the Schrodinger will give us a report What is Schrodinger(2/2) Failpoint injection ● Failpoints are used to add code points where errors may be injected ● Why we need failpoints cases func someFunc() string { // gofail: var SomeFuncString string // // this is called when the failpoint is triggered // return SomeFuncString return "default" } About gofail ● An implementation of FreeBSD0 码力 | 32 页 | 1.76 MB | 6 月前3
TiDB中文技术文档Alpha - 408 - 本文档使用 书栈(BookStack.CN) 构建 优化 Coprocessor count (*) 和点查 unique index 的性能 增加更多的 Failpoint 以及稳定性测试 case 解决 PD 和 TiKV 之间重连的问题 增强数据恢复工具 tikv-ctl 的功能 Region 支持按 table 进行分裂 支持 Delete Range0 码力 | 444 页 | 4.89 MB | 6 月前3
Just-In-Time Compilation: The Next Big Thing. 10CPP INJECTION / SECURITY BREACH CPP INJECTION / SECURITY BREACH 5 . 11CPP INJECTION / SECURITY BREACH CPP INJECTION / SECURITY BREACH 5 . 11CPP INJECTION / SECURITY BREACH CPP INJECTION / SECURITY Password='' 5 . 11CPP INJECTION / SECURITY BREACH CPP INJECTION / SECURITY BREACH CPP INJECTION CPP INJECTION SELECT * FROM Users WHERE Name='' or 1==1--' and Password='' 5 . 11CPP INJECTION / SECURITY BREACH BREACH CPP INJECTION / SECURITY BREACH CPP INJECTION CPP INJECTION SELECT * FROM Users WHERE Name='' or 1==1--' and Password='' int main() { jit<"[]{ std::cout << \""s + std::getenv("USER") + "\"; }">();0 码力 | 222 页 | 5.45 MB | 6 月前3
Newer Isn't Always Better16 Global Variables Design Patterns Singleton Meyers Singleton Monostate Dependency Injection (DI) Timelineatomosspace.com | 17 • Hold one copy of global data/interface and allow others access each of the using objects New Trend – Dependency Injectionatomosspace.com | 23 Aside: Dependency Injection (DI) Vs Dependency Inversion Principle (DIP)atomosspace.com | 24 • Eliminates the dependency by Injected 3 ways • Interface/Template Parameter Injection (Type 1) • Setter (Type 2) • Constructor (Type 3) • One Object being shared Dependency Injection (DI)atomosspace.com | 26 class Plotting {0 码力 | 60 页 | 1.34 MB | 6 月前3
Reflection Is Not Contemplationlong-winded, circumlocutory, and unceasingly inclined toward linguistic superfluity. •String Injection: offer a primitive that splices CT strings into code • Horribly unstructured. Also… can’t use macros •Strings opaque/unwieldy? Use token sequences instead of strings • Cost: one added literal kind •Injection risks and dangers? Restrict string expansion • Carefully controlled escapes, interpolation-style identifier • \tokens( expr ) expands another token sequence •Inside any consteval function: • queue_injection( tokens_expr ) injects a token sequence into the current declaration context constexpr auto r0 码力 | 45 页 | 2.45 MB | 6 月前3
Retiring the Singleton Patternassignment)Drawbacks of a Singleton • Acts as hidden dependencies in functions that use it • No dependency injection for testing • Initialization is out of your control • Multiple runs can yield different results - at least - source compatible • Express the involvement of outside agencies • Allow dependency injection for testing purposes Bloomberg 12Bloomberg 13 // processor.cpp Response sendData(const Data& data must be source compatible • Express the involvement of an outside agency • Allow dependency injection for testing purposes // processor.h Response sendData(const Data& data, CommSingleton* comms0 码力 | 70 页 | 1.59 MB | 6 月前3
Peering Forward: C++'s Next Decadeand parallelism) Type and memory safety improvements Reflection + code generation (aka ‘injection’/…) Contracts means “some initial parts already voted into C++26”3 Major advances are improvements target: parity with other modern languages Reflection + code generation (aka ‘injection’/…) part of our sea change to compile-time programming arguably most-impactful feature is the language we want at compile time C++ is the language we want on GPUs14 code generation/injection generative extensions introspection of closure types function parameters reflection, splicers0 码力 | 84 页 | 6.21 MB | 6 月前3
BehaviorTree.CPP: Task Planning for Robots and Virtual Agentsbehaviors offline (logging) or at run-time (monitoring). ● Advanced debugging tools such as fault injection, interactive debugging and more. ● Implements a novel pre-post condition extension, that reduces Collect statistics about the execution of the tree and the actions in a non-intrusive way.Code injection and interactive debuggingUser can inject at deployment-time or run-time functions to be execute "dummy ones". ● Do fault injection in the tree, to test how the robot behave when other branches are taken. ● This functionality is integrated with our remote GUI. Code injection and interactive debuggingA0 码力 | 59 页 | 7.97 MB | 6 月前3
Leveraging a Functional Approach for More Testable and Maintainable ROS 2 Codeor_else(return_empty_response) .value(); }DI and Functional Programming ● With Dependency Injection (DI)! templateusing ServiceCallback = std::function mw_; Map map_; };DI and Functional Programming ● With Dependency Injection (DI)! ○ DI is used to move or “inject” objects into another object template private: std::unique_ptr mw_; Map map_; };● With Dependency Injection (DI)! ○ DI is used to move or “inject” objects into another object ● There still needs to be 0 码力 | 200 页 | 1.77 MB | 6 月前3
共 98 条
- 1
- 2
- 3
- 4
- 5
- 6
- 10













