KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am looking at depency injection, I can see the benefits but I am having problems with the syntax it creates. I have this example public class BusinessProducts { IDataContext _dx; BusinessProducts(IDataContext dx) { _dx = dx; } public List<Product> GetProducts() { return dx.GetProducts(); } } The problem is that I don't want to write BusinessProducts bp = new BusinessProducts(dataContextImplementation); I would continue to write BusinessProducts bp = new BusinessProducts(); because I feel the first alternative just feels unatural. I dont want to know what the BusinessProduct "depends" on to get the products, also I feel it makes my code more unreadable. Is there any alternatives to this approach as I would like to keep my original syntax for creating objects but I would like to still be able to fake the dependencies when unit testing or is it this dependecy injection frameworks can do for me? I am coding in c# but alternatives from other languages is welcome
Tags (comma-separated)
Save Edits
Cancel