i can't understand difference between these two pattern. i feel these two are same but different program patterns. just entered into spring.
pattern 1 - dependency injection by constructor and setter method
class Employee{
Address address ;
public Employee(Address address ) {
this.address = address;
}
public void setAddress(Address address ) {
this.address = address;
}
}
Pattern 2 - old java object creation
class Employee{
Address address ;
public Employee(){
address = new Address();
}
}
i can't understand why pattern 1 is good(loosly coupled) and pattern 2 is tightly coupled. anyhow Employee should be depending on Address class .
Aucun commentaire:
Enregistrer un commentaire