Re: Basic Concept Question Why Interface?
From: Nick Malik (nickmalik_at_hotmail.nospam.com)
Date: 06/15/04
- Next message: John Baro: "Re: Improve Performance of UI"
- Previous message: Nick Malik: "Re: Command Line Application"
- In reply to: jm: "Basic Concept Question Why Interface?"
- Next in thread: Simon Smith: "Re: Basic Concept Question Why Interface?"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Jun 2004 02:54:58 GMT
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" <john_20_28_2000@yahoo.com> wrote in message
news:c67e4bdd.0406141337.10d9ec47@posting.google.com...
> Consider:
>
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbconwhenshouldiimplementinterfacesinmycomponent.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.
- Next message: John Baro: "Re: Improve Performance of UI"
- Previous message: Nick Malik: "Re: Command Line Application"
- In reply to: jm: "Basic Concept Question Why Interface?"
- Next in thread: Simon Smith: "Re: Basic Concept Question Why Interface?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|