The answer can be found by digging deeper into Design Patterns.
Consider:
http://home.earthlink.net/~huston2/dp/patterns.html
(just one of thousands of links about design patterns, although Vince Huston
is a bit more "convinced" than most folks. I like the site for its
tutorials).
If you drill into each of the design patterns under the Gang-of-Four
section, you will begin to notice two things:
1) These are EXCELLENT solutions to some really common problems, (ranging
from simple to really difficult problems). If you really take the time to
learn these patterns, your programming will improve dramatically, and
2) Nearly every one of these design patterns REQUIRES the use of interface
definitions in order to create the concept of a contract where any object
that implements the contract can be substituted for any other object that
also implements the contract. (this ability to substitute forms the
implementation foundation of the Liskov Substitution Principle).
In other words, delve deeper. Keep asking questions. Pick up a copy of
"Design Patterns Explained" by Alan Shalloway and James Trott. Then read
it. Then read it again.
And enjoy this journey... it's a fun ride.
--- Nick
"jm" <jo*************@yahoo.com> wrote in message
news:c6**************************@posting.google.c om...
Consider:
http://msdn.microsoft.com/library/de...ycomponent.asp
// Code for the IAccount interface module.
public interface IAccount
{
void PostInterest();
void DeductFees(IFeeSchedule feeSchedule);
}
class BusinessAccount : IAccount
{
void IAccount.PostInterest()
{
// Code to post interest using the most favorable rate.
}
void IAccount.DeductFees(IFeeSchedule feeSchedule)
{
// Code to change a preferred rate for various services.
}
}
Note An interface is a contract. You must implement all of the
properties and methods in the interface.
I do not understand why Interface was necessary. Why not just have
the class BusinessAccount and two functions in it PostInterest() and
DeductFees()?
Thank you.