I am in the process of converting all my parameters, return types, classes to all use Interfaces instead ie. IUser instead of User.
Besides the extra code required to maintain this, are their any negatives to this approach?
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.
This isn’t an uncommon approach, especially if you do a lot of mocking; however, it has issues with:
You need to figure out whether the advantages of mocking etc outweigh these issues. It might be that you use
IUserin most scenarios, but (for example) at the comms layer it may be simpler to use raw DTOs rather than interfaces.Note that I’m applying the above to classes. If you involve structs, then remember that in most cases this will involve boxing too.