Your SlideShare is downloading. ×
  • Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Wake up Neo... Dependencies have you

  • 747 views
Published

 

Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
747
On SlideShare
0
From Embeds
0
Number of Embeds
3

Actions

Shares
Downloads
4
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Ivan Mosiev —software architect,AltexSofti.k.mosev@gmail.comhttp://verber.kh.ua @polny_otec
  • 2. Wake up, Neo...Dependencies have you
  • 3. Ideal world
  • 4. Ideal Unit
  • 5. Welcome to thereal world
  • 6. Real UnitDependencies
  • 7. Imagine, there is nodependencies
  • 8. Imaginary UnitIndirect Indirect Input Output
  • 9. Indirect Input$internal = $Dependency->something;function dependency() { return $something; }function dependency() { throw new Exception_WTF; }function dependency(&$by_ref) { $by_ref++; }
  • 10. Indirect Output$Dep->something = $internal;$Dep->doSomething($internal);
  • 11. Stub
  • 12. Dummy
  • 13. Fake
  • 14. Spy
  • 15. Mock
  • 16. This is my world, my world!function runMatrix() { $agents = array(); while (TRUE) { $agents[] = new AgentSmith(); }}
  • 17. Dependency Injection
  • 18. Refactoring: step 0function doSomething() { $auth = new Service(); … return $profit;}
  • 19. Refactoring: step 1private function getService() { return new Service();}function doSomething() { $service = $this->getService(); … return $profit;}
  • 20. Refactoring: step 2private $_service;private function getService() { If (!$this->_service) $this->_service = new Service(); return $this->_service;}function setService(IService $service) { $this->_service = $service;}
  • 21. do { $the->same();} while ($deps_count > 0);
  • 22. function getService() { if (!$this->_service) $this->_service = return Service(); return $this->_service;}
  • 23. Inversion of ControlIoC Container store information aboutdependenciesDependencies instantiated by ContainerrecursivelyDependencies injected into Object by ServiceContainer
  • 24. Benefits?Mock and test everythingLoose couplingComponents reuse
  • 25. Now you know kung fu