|
-
May 3rd, 2007, 02:25 PM
#1
program to an interface not implementation
We all heard of this before from the the gang f four and other locations. Maybe lack of sleep is confusing my brain...here is my question
I have a c# user control. have 2 methods add and subtract.
case1:
they are declared as public methods so when the user control is instantiated, say in a form, one can do
Code:
usercontrol.add(1,1);
and
Code:
usercontrol.subtract(100,1);
The form where the control is instantiated does not know how the add and subtract methods are implemented. would that be a fair statement?
case2:
same as case1 except that add and subtracts methods are exposed via interfaces and one gets to them in usual manner
the question now is that in either of the 2 cases the client has no ideas on how the methods are implemented and in case of a user control why would i choose to go with interfaces and does this statement 'program to an interface not implementation' hold valid??
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|