Or you may want one collection class to be able to operate on particular
members across similar classes that require a certain operation.
Implementing the same interface to those classes will make this very
possible, as the collection members are defined relative to that interface.
Maybe you have a method that does a desired operation on data members (sorry
for redefining a method ), again across classes (maybe similar or can even
be different), such a method that takes an interface as an parameter will
make this very possible as that interface will be implemented to those
classes. Containing the relevant members to be implemented
Not really convention, as for reason, could be the above, I worked for one
place where the architects bestowed interfaces to the coders that had to
implement before coding the class bodies, why? I guess as well as extreme
programming we also have totalitarian programming. But everyone was happy in
the end, documentation was also allot easier.
- SpotNet
: Kiran wrote:
: > Hi,
: >
: > As a convention we always create interfaces before creating classes for
: > class libraries.
: >
: > we then implement this interface in a class.
: >
: > Can someone point out the reasons\advantages for doing this in a simple
: > way.
:
:
: Say you want to input a Day and get back the temperature for that Day.
:
: But you want it to be global, so some use Fahrenheit, some Celsius.
:
:
: The inteface is the same,
:
: int temp(DateTime day)
:
:
: But the calculations behind the method are different and it returns
: different values.
:
:
:
:
:
: >
: > Thanks
: > Kiran