Difference between IList and List

 
108   96.6
Jun 11, 2012
 

I already Googled the difference between List and IList and it still is not that clear to me.
In the Patterns in Action dofactory project, the List are used in Business and Data layer but when they map it in the service layer the send it back as IList.

What are teh benefits of mapping it to an IList?
Could I simply send back a List and the application would function the same?

Thanks a lot.
Dennis



377   99.9
Jun 14, 2012
Program to interface not to class.
IList is an interface and List is concrete class. 
Let's suppose you have a business object where you want to use a object of type Apple. May be it is fine for now but later you may need to support Mango type object. In that case you may probably need to change the business layer. 
To get rid of these tight coupling you need to use interface like IFruit. Then your business layer will not depend just on Apple class and you will get rid of tight coupling. 
 1 comment
 
Correct ! --- Tarriq Ferrose Khan  Jun 21, 2012

50   50
Aug 08, 2012
To understand the difference between List and IList you need to understand the difference between classes and interfaces.
It's the basic of OO development. You should first learn this before you continue on Design Patterns.