SlideShare a Scribd company logo
1 of 10
DESIGN PATTERN
BY LUIS GINANJAR
COMPLICATED MANUAL TEST PER CASE
TOO MANY HUMAN ERROR
Module A
Case 1
Case 2
Case 3
SOLUTION : UNIT TEST
WE CREATE TEST BY CODE, SO IT CAN’T FORGET OR LOST
Module A
Case 1
Case 2
Case 3
UNIT TEST
UNIT TEST BENEFIT
Quick Feedback
Simplifies Integration
Form of sample code
Modular object
Saves development time
Inspires confidence
Better Design
PROBLEM UNIT TEST :
DEPENDENCY TO ANOTHER OBJECT
Module A
Case 1
Case 2
Case 3
UNIT TEST
DB
API
Module
B
SOLUTION : INTERFACE
Module A
IDB
IAPI
IModule
B
DB
API
Module
B
Interface
INTERFACE WITH MOCK
CHANGE DEPENDENCY TO FAKE OBJECT, SO WE CAN FOCUS TESTING ON
PRIMARY OBJECT
Module A
IDB
IAPI
IModule
B
Fake
DB
Fake
API
Fake
Module
B
Interface
Unit Test
Interfac
e
IMPLEMENTATION
Module A
Fake ModuleUnit Test
OF Initiate ModuleAGetModuleA()
Real Module
App
(OF as assembler module / object, OF can determine create real or fake module / object)
THIS TECHNIQUE IS CALLED :
DEPENDENCY INJECTION
Don't initiate specific object or specific implementation inside,
to prevent tight coupling. ~Uncle Bob
UNIT TEST AS DOCUMENTATION TECHNICAL SPEC
WE CAN REUSE SAME TEST AND INTERFACE FOR ANOTHER PLATFORM OR
LANGUAGE, SO WE CAN PREVENT REPEATING ERROR
Interface &
Unit Test
iOS Android

More Related Content

What's hot

Iisrt zz mamatha
Iisrt zz mamathaIisrt zz mamatha
Iisrt zz mamatha
IISRT
 
Testing Android apps with Robotium
Testing Android apps with RobotiumTesting Android apps with Robotium
Testing Android apps with Robotium
Stephen Gilmore
 

What's hot (20)

Code Review
Code ReviewCode Review
Code Review
 
Meningkatkan SOC dan Reusabillity Kode dengan Duo DI - Sidiq Permana (CIO Nus...
Meningkatkan SOC dan Reusabillity Kode dengan Duo DI - Sidiq Permana (CIO Nus...Meningkatkan SOC dan Reusabillity Kode dengan Duo DI - Sidiq Permana (CIO Nus...
Meningkatkan SOC dan Reusabillity Kode dengan Duo DI - Sidiq Permana (CIO Nus...
 
Programming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStringsProgramming katas for Software Testers - CounterStrings
Programming katas for Software Testers - CounterStrings
 
Let's Explore C# 6
Let's Explore C# 6Let's Explore C# 6
Let's Explore C# 6
 
Code Review
Code ReviewCode Review
Code Review
 
Concurrent Applications with F# Agents
Concurrent Applications with F# AgentsConcurrent Applications with F# Agents
Concurrent Applications with F# Agents
 
When will ai take my job as a tester
When will ai take my job as a testerWhen will ai take my job as a tester
When will ai take my job as a tester
 
FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09FluentSelenium Presentation Code Camp09
FluentSelenium Presentation Code Camp09
 
Reptor_Poster
Reptor_PosterReptor_Poster
Reptor_Poster
 
Improving Estimates
Improving EstimatesImproving Estimates
Improving Estimates
 
Improving Code Quality Through Effective Review Process
Improving Code Quality Through Effective  Review ProcessImproving Code Quality Through Effective  Review Process
Improving Code Quality Through Effective Review Process
 
Iisrt zz mamatha
Iisrt zz mamathaIisrt zz mamatha
Iisrt zz mamatha
 
SeleniumConf 2017: Writing stable, maintainable UI regression tests
SeleniumConf 2017: Writing stable, maintainable UI regression testsSeleniumConf 2017: Writing stable, maintainable UI regression tests
SeleniumConf 2017: Writing stable, maintainable UI regression tests
 
Reverse algorithm how_to_guide
Reverse algorithm how_to_guideReverse algorithm how_to_guide
Reverse algorithm how_to_guide
 
AspectMock
AspectMockAspectMock
AspectMock
 
Debugging C# Applications
Debugging C# ApplicationsDebugging C# Applications
Debugging C# Applications
 
Testing Android apps with Robotium
Testing Android apps with RobotiumTesting Android apps with Robotium
Testing Android apps with Robotium
 
Calc app
Calc appCalc app
Calc app
 
Functional testing vs non functional testing | Difference Between Functional ...
Functional testing vs non functional testing | Difference Between Functional ...Functional testing vs non functional testing | Difference Between Functional ...
Functional testing vs non functional testing | Difference Between Functional ...
 
Cool .NET tools, techniques and libraries
Cool .NET tools, techniques and librariesCool .NET tools, techniques and libraries
Cool .NET tools, techniques and libraries
 

Similar to Dependency Injection Pattern

Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009
Grig Gheorghiu
 
Unit testing using Mock objects and dependency injection
Unit testing using Mock objects and dependency injectionUnit testing using Mock objects and dependency injection
Unit testing using Mock objects and dependency injection
Yn Reddy
 

Similar to Dependency Injection Pattern (20)

Understanding Unit Testing
Understanding Unit TestingUnderstanding Unit Testing
Understanding Unit Testing
 
Software Engineering - RS3
Software Engineering - RS3Software Engineering - RS3
Software Engineering - RS3
 
Understand the AI-powered test automation with Magic Pod
Understand the AI-powered test automation with Magic PodUnderstand the AI-powered test automation with Magic Pod
Understand the AI-powered test automation with Magic Pod
 
Unit tests benefits
Unit tests benefitsUnit tests benefits
Unit tests benefits
 
Android Test Pyramid - Ágiles 2013
Android Test Pyramid - Ágiles 2013Android Test Pyramid - Ágiles 2013
Android Test Pyramid - Ágiles 2013
 
Workshop unit test
Workshop   unit testWorkshop   unit test
Workshop unit test
 
Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009Agile Testing Pasadena JUG Aug2009
Agile Testing Pasadena JUG Aug2009
 
Unit testing using Mock objects and dependency injection
Unit testing using Mock objects and dependency injectionUnit testing using Mock objects and dependency injection
Unit testing using Mock objects and dependency injection
 
Unit Testing in Android
Unit Testing in AndroidUnit Testing in Android
Unit Testing in Android
 
Verification and Validation in Manual Testing
Verification and Validation in Manual TestingVerification and Validation in Manual Testing
Verification and Validation in Manual Testing
 
Automated Testing on iOS
Automated Testing on iOSAutomated Testing on iOS
Automated Testing on iOS
 
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dic...
 
Test driven development
Test driven developmentTest driven development
Test driven development
 
UI Testing
UI TestingUI Testing
UI Testing
 
MPP-UPNVJ
MPP-UPNVJMPP-UPNVJ
MPP-UPNVJ
 
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
Developers’ mDay u Banjoj Luci - Milan Popović, PHP Srbija – Testimony (about...
 
Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)Module 2: C# 3.0 Language Enhancements (Material)
Module 2: C# 3.0 Language Enhancements (Material)
 
Beyond Agile Testing to Lean Development — Rakuten Technology Conference
Beyond Agile Testing to Lean Development — Rakuten Technology ConferenceBeyond Agile Testing to Lean Development — Rakuten Technology Conference
Beyond Agile Testing to Lean Development — Rakuten Technology Conference
 
Loopt unit test experiences
Loopt unit test experiencesLoopt unit test experiences
Loopt unit test experiences
 
Unit Testing and Why it Matters
Unit Testing and Why it MattersUnit Testing and Why it Matters
Unit Testing and Why it Matters
 

Recently uploaded

☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
mikehavy0
 
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
A
 

Recently uploaded (20)

☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
☎️Looking for Abortion Pills? Contact +27791653574.. 💊💊Available in Gaborone ...
 
Diploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdfDiploma Engineering Drawing Qp-2024 Ece .pdf
Diploma Engineering Drawing Qp-2024 Ece .pdf
 
Autodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptxAutodesk Construction Cloud (Autodesk Build).pptx
Autodesk Construction Cloud (Autodesk Build).pptx
 
Basics of Relay for Engineering Students
Basics of Relay for Engineering StudentsBasics of Relay for Engineering Students
Basics of Relay for Engineering Students
 
DBMS-Report on Student management system.pptx
DBMS-Report on Student management system.pptxDBMS-Report on Student management system.pptx
DBMS-Report on Student management system.pptx
 
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
NO1 Best Powerful Vashikaran Specialist Baba Vashikaran Specialist For Love V...
 
Filters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility ApplicationsFilters for Electromagnetic Compatibility Applications
Filters for Electromagnetic Compatibility Applications
 
Presentation on Slab, Beam, Column, and Foundation/Footing
Presentation on Slab,  Beam, Column, and Foundation/FootingPresentation on Slab,  Beam, Column, and Foundation/Footing
Presentation on Slab, Beam, Column, and Foundation/Footing
 
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdfInstruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
Instruct Nirmaana 24-Smart and Lean Construction Through Technology.pdf
 
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...8th International Conference on Soft Computing, Mathematics and Control (SMC ...
8th International Conference on Soft Computing, Mathematics and Control (SMC ...
 
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
NEWLETTER FRANCE HELICES/ SDS SURFACE DRIVES - MAY 2024
 
Worksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptxWorksharing and 3D Modeling with Revit.pptx
Worksharing and 3D Modeling with Revit.pptx
 
Dynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptxDynamo Scripts for Task IDs and Space Naming.pptx
Dynamo Scripts for Task IDs and Space Naming.pptx
 
Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...Developing a smart system for infant incubators using the internet of things ...
Developing a smart system for infant incubators using the internet of things ...
 
Signal Processing and Linear System Analysis
Signal Processing and Linear System AnalysisSignal Processing and Linear System Analysis
Signal Processing and Linear System Analysis
 
5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...5G and 6G refer to generations of mobile network technology, each representin...
5G and 6G refer to generations of mobile network technology, each representin...
 
Circuit Breakers for Engineering Students
Circuit Breakers for Engineering StudentsCircuit Breakers for Engineering Students
Circuit Breakers for Engineering Students
 
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and ToolsMaximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
Maximizing Incident Investigation Efficacy in Oil & Gas: Techniques and Tools
 
handbook on reinforce concrete and detailing
handbook on reinforce concrete and detailinghandbook on reinforce concrete and detailing
handbook on reinforce concrete and detailing
 
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
一比一原版(NEU毕业证书)东北大学毕业证成绩单原件一模一样
 

Dependency Injection Pattern

  • 2. COMPLICATED MANUAL TEST PER CASE TOO MANY HUMAN ERROR Module A Case 1 Case 2 Case 3
  • 3. SOLUTION : UNIT TEST WE CREATE TEST BY CODE, SO IT CAN’T FORGET OR LOST Module A Case 1 Case 2 Case 3 UNIT TEST
  • 4. UNIT TEST BENEFIT Quick Feedback Simplifies Integration Form of sample code Modular object Saves development time Inspires confidence Better Design
  • 5. PROBLEM UNIT TEST : DEPENDENCY TO ANOTHER OBJECT Module A Case 1 Case 2 Case 3 UNIT TEST DB API Module B
  • 6. SOLUTION : INTERFACE Module A IDB IAPI IModule B DB API Module B Interface
  • 7. INTERFACE WITH MOCK CHANGE DEPENDENCY TO FAKE OBJECT, SO WE CAN FOCUS TESTING ON PRIMARY OBJECT Module A IDB IAPI IModule B Fake DB Fake API Fake Module B Interface Unit Test
  • 8. Interfac e IMPLEMENTATION Module A Fake ModuleUnit Test OF Initiate ModuleAGetModuleA() Real Module App (OF as assembler module / object, OF can determine create real or fake module / object)
  • 9. THIS TECHNIQUE IS CALLED : DEPENDENCY INJECTION Don't initiate specific object or specific implementation inside, to prevent tight coupling. ~Uncle Bob
  • 10. UNIT TEST AS DOCUMENTATION TECHNICAL SPEC WE CAN REUSE SAME TEST AND INTERFACE FOR ANOTHER PLATFORM OR LANGUAGE, SO WE CAN PREVENT REPEATING ERROR Interface & Unit Test iOS Android