VisualStudioFeeds

All Visual Studio blogs in one place

AddThis Social Bookmark Button
The premise of coding to interfaces has been around for awhile now. The concept is simple. Given a definition of something you create things based on that definition. That might be a horrible description of an interface but I didn’t want to go all Computer Science on you. Interface? What’s an Interface? Here’s a simple interface:
1: interface ICustomerService 2: { 3: IEnumerable GetAllCustomers();
4: }
Pretty basic. We have a Customer class somewhere and this interface describes a method called GetAllCustomers that will return you a list of Customer objects. With an interface you don’t have an implementation. There’s no code here to say where we get the customers from, just that we expect this to return us a list of them. Now in our code we can write something like this:
1: public void DisplayAllCustomers(ICustomerService service) 2: { 3: foreach (var...(Read whole news on source site)

Search

Subscribe

Enter your email address:

Delivered by FeedBurner

Increase your website traffic with Attracta.com

Contact

Email:
Subject:
Message:
Anti-spam: How many eyes has a typical person?

Follow us on FB

Home : Blog List : Fear and Loathing : Code to Interfaces. Right. What’s an Interface?