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.
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).
There are many advantages of using interface. You would do better to read up a good book on principles of object oriented technology. Or just search for why use interfaces. But the short answer is use interfaces.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With