code_junkie

What is dependency injection?

Nov 11th, 2011
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. public SomeClass() {
  2. myObject = Factory.getObject();
  3. }
  4.  
  5. public SomeClass (MyClass myObject) {
  6. this.myObject = myObject;
  7. }
  8.  
  9. public class PersonService {
  10. public void addManager( Person employee, Person newManager ) { ... }
  11. public void removeManager( Person employee, Person oldManager ) { ... }
  12. public Group getGroupByManager( Person manager ) { ... }
  13. }
  14.  
  15. public class GroupMembershipService() {
  16. public void addPersonToGroup( Person person, Group group ) { ... }
  17. public void removePersonFromGroup( Person person, Group group ) { ... }
  18. }
  19.  
  20. class Car{
  21. private Wheel wh= new NepaliRubberWheel();
  22. private Battery bt= new ExcideBattery();
  23. //rest
  24. }
Add Comment
Please, Sign In to add comment