Should communication between layers always be done using an interface or is it OK to access objects directly?
For example between the business logic and business object layers/projects.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Accessing objects directly creates very tight coupling between objects – “what do you mean, you refactored Customer.FirstName to Customer.Name.GivenName? Now I have to rewrite my code, oh noes!”
Programming against an interface gives you more power to change the implementation later on, perhaps swap in a completely new one (even dynamically, at runtime). It may seem like bother, but for anything bigger than Hello World, tight coupling will come back to bite you in the butt (or whomever that maintains the code after the guy who maintained it after you).